iOS - UIVIewController中的UITableView不显示所有行[Swift](iOS - UITableView in UIVIewController doesn't display all rows [Swift])
我在
UIViewController
遇到了我的UITableView
的错误。 我会试着解释一下情况和问题。我有一个
TabBarController
,其视图是带有UITableView
的UIViewController
。 我没有使用UITableViewController
因为我的UIViewController
上有一些特定的控件。所以,当我的
UIViewController
不是我的TabBarController
的孩子时,一切都还可以:所有行都正确显示。但是,当我将我的
UIViewController
设置为我的TabBarController
的子TabBarController
,我遇到了这个错误:只显示了一些行(在所有情况下都会显示一个超过三十行)。我只是不明白发生了什么。 我的代码似乎工作,但只有当我的
UIViewController
不是我的TabBarController
的孩子。在这种情况下是否还有其他方法可以添加?
有我的
UIViewController
的代码:class ProfileController: UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var tableChallenges: UITableView! @IBOutlet weak var profileTabs: UISegmentedControl! var pageViewController : UIPageViewController! override func viewDidLoad() { super.viewDidLoad() self.tableChallenges.dataSource = self self.tableChallenges.delegate = self self.tableChallenges.reloadData() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 5 } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("challengeCustomCell", forIndexPath: indexPath) as! ChallengeCustomCell switch(self.profileTabs.selectedSegmentIndex) { case 0: cell.challengeSuccededOrFailedImage.hidden = true break case 1: cell.challengeSuccededOrFailedImage.hidden = false cell.challengeSuccededOrFailedImage.image = UIImage(named: "challenge-succeded") break case 2: cell.challengeSuccededOrFailedImage.hidden = false cell.challengeSuccededOrFailedImage.image = UIImage(named: "challenge-failed") break case 3: cell.challengeSuccededOrFailedImage.hidden = true break default: break } return cell } @IBAction func selectedItemChanged(sender: AnyObject) { self.tableChallenges.reloadData() } }
在此先感谢您的回答! :)
I'm facing a bug with my
UITableView
inUIViewController
. I'll try to explain what's the situation and my problem.I have a
TabBarController
which a view is aUIViewController
with aUITableView
. I don't use aUITableViewController
because I have some specifics controls on myUIViewController
.So, when my
UIViewController
isn't a child of myTabBarController
, everything is okay : all rows are displayed correctly.But, when I set my
UIViewController
as a child of myTabBarController
, I have this bug : only some rows are displayed (one over threem exactly, in all scenarios).I just don't understand what's happening. My code seems working, but only when my
UIViewController
isn't a child of myTabBarController
.Is there another method to add in this case ?
There is the code of my
UIViewController
:class ProfileController: UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var tableChallenges: UITableView! @IBOutlet weak var profileTabs: UISegmentedControl! var pageViewController : UIPageViewController! override func viewDidLoad() { super.viewDidLoad() self.tableChallenges.dataSource = self self.tableChallenges.delegate = self self.tableChallenges.reloadData() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 5 } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("challengeCustomCell", forIndexPath: indexPath) as! ChallengeCustomCell switch(self.profileTabs.selectedSegmentIndex) { case 0: cell.challengeSuccededOrFailedImage.hidden = true break case 1: cell.challengeSuccededOrFailedImage.hidden = false cell.challengeSuccededOrFailedImage.image = UIImage(named: "challenge-succeded") break case 2: cell.challengeSuccededOrFailedImage.hidden = false cell.challengeSuccededOrFailedImage.image = UIImage(named: "challenge-failed") break case 3: cell.challengeSuccededOrFailedImage.hidden = true break default: break } return cell } @IBAction func selectedItemChanged(sender: AnyObject) { self.tableChallenges.reloadData() } }
Thanks in advance for your answers ! :)
原文:https://stackoverflow.com/questions/33177968
最满意答案
像URI一样的URI中的东西在URI与重写规则匹配之前被解码。 这意味着
%20
会变成一个空格,而你的正则表达式\w
将不会与空格相匹配。 尝试将正则表达式更改为:RewriteRule ^about/([\w\s]+)$ about_user.php?about_key=$1
Stuff in the URI like
%20
gets decoded before the URI is matched against rewrite rules. That means%20
gets turned into a space, and your regex\w
won't match against whitespace. Try changing your regex to:RewriteRule ^about/([\w\s]+)$ about_user.php?about_key=$1
相关问答
更多-
请帮忙测试一下“裘会强”这个名字能得多少分[2022-10-05]
20 -
.htaccess重写规则在传递多个变量时导致错误404(.htaccess rewrite rule causes an error 404 when multiple variables are passed)[2023-12-01]
你的正则表达式不包括%20或空格之类的东西,试着让它接受一切:RewriteEngine On RewriteBase /posts/ RewriteRule ^([a-zA-Z0-9]+)/(.+)$ post.php?date=$1&title=$2 您可能需要使用NE和/或B标记,具体取决于您在URL中使用的编码内容类型:RewriteEng ... -
您必须将要重写的目的地排除在外: RewriteRule ^((?!index\.php).*)$ /index.php/$1 [QSA,L] 否则你会得到一个重写循环错误,因为模式^(.*)$也匹配uri index.php You have to exclude the destination you are rewriting to : RewriteRule ^((?!index\.php).*)$ /index.php/$1 [QSA,L] otherwise you will get a ...
-
htaccess重写规则为301(htaccess Rewrite Rule for 301)[2022-04-10]
将此代码放在DOCUMENT_ROOT/.htaccess文件中: RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} \s/11/video_player\.php\?id=([^\s&]+) [NC] RewriteRule ^ lesson/%1? [R=302,L] RewriteRule ^lesson/([^/.]+)/?$ /11/video_player.php?id=$1 [L,QSA,NC] Put this code ... -
像URI一样的URI中的东西在URI与重写规则匹配之前被解码。 这意味着%20会变成一个空格,而你的正则表达式\w将不会与空格相匹配。 尝试将正则表达式更改为: RewriteRule ^about/([\w\s]+)$ about_user.php?about_key=$1 Stuff in the URI like %20 gets decoded before the URI is matched against rewrite rules. That means %20 gets turned i ...
-
第二次尝试时,你得到500,因为你创建了一个无限循环: ^(.*)$会一次又一次地匹配profile.php?user=xxx ...当你尝试使用^(.*)/$因为(没有尾部斜杠)这不匹配profile.php?user=xxx时不是这种profile.php?user=xxx 相反,你可以这样做 RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC] RewriteCond %{REQUEST_URI} !\.(css|jpg| ...
-
我相信这应该可以使它匹配,即使它有URL的附加部分: RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^adverts/([^/]+)/([^/]+)(/(.*))?$ adverts.php?kat=$1&podkat=$2 [L] I believe this should do the trick for making it match even if it has additiona ...
-
用htaccess重写规则(rewrite rule with htaccess)[2021-09-17]
尝试这个 Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z]{2,4})\.([\w-]+)/?$ index.php?prefix=$1&username=$2 [QSA,L,NC] 这条单一规则可以处理所有情况。 \w相当于[a-zA-Z0-9_] 。 仅指定了[az]因为该规则现在使用[ ... -
按照以下顺序制定规则: ErrorDocument 404 /404.php Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^www\.airporttransfer4u\.co\.uk$ [NC] RewriteRule ^(.*)$ http://www.airporttransfer4u.co.uk/$1 [L,R=301] RewriteRule ^rec ...
-
您的问题是您的订单。 /website/occasion/category首先被重写为/website/occasion/category.php ,然后无法匹配第二条规则。 RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)(/)?$ index.php?occ=$1&cat=$2 [L] RewriteRule ^(.*)$ $1.php 更改顺序并将[L]参数添加到规则(成功执行后停止执行后续规则)应该可以解决问题。 Your Problem is your order ...