viewDidAppear for UITableViewCell

前端 未结 3 499
孤街浪徒
孤街浪徒 2021-02-03 19:53

I usually use viewDidAppear method to do some UI stuff on the view after it finished appearing and I used this method in various situations were it was very useful,

3条回答
  •  终归单人心
    2021-02-03 20:53

    The method viewDidLoad is related to UIViewController and its subclasses, so we cannot use this in UITableViewCell, which is a UIView subclass. The solution I used in one of my app is to override the layoutSubViews method of UITableViewCell, and I delayed the action for some time as below.

    - (void)layoutSubViews
    {
         [super layoutSubviews];
    
         [self performSelector:@selector(myMethod) withObject:nil afterDelay:1.0];
    }
    

提交回复
热议问题