首页 \ 问答 \ iOS - UIVIewController中的UITableView不显示所有行[Swift](iOS - UITableView in UIVIewController doesn't display all rows [Swift])

iOS - UIVIewController中的UITableView不显示所有行[Swift](iOS - UITableView in UIVIewController doesn't display all rows [Swift])

我在UIViewController遇到了我的UITableView的错误。 我会试着解释一下情况和问题。

我有一个TabBarController ,其视图是带有UITableViewUIViewController 。 我没有使用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 in UIViewController. I'll try to explain what's the situation and my problem.

I have a TabBarController which a view is a UIViewController with a UITableView. I don't use a UITableViewController because I have some specifics controls on my UIViewController.

So, when my UIViewController isn't a child of my TabBarController, everything is okay : all rows are displayed correctly.

But, when I set my UIViewController as a child of my TabBarController, 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 my TabBarController.

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
更新时间:2022-05-11 21:05

最满意答案

像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

相关问答

更多
  • 你的正则表达式不包括%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 ...
  • 将此代码放在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 ...
  • 尝试这个 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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)