开发者

prevent viewcontroller from being pushed to splitviewcontroller twice

开发者 https://www.devze.com 2023-01-22 10:42 出处:网络
I 开发者_StackOverflow社区want to prevent users from making the same selection twice or more and just pushing and pushing the same view controller onto the stackTry...

I 开发者_StackOverflow社区want to prevent users from making the same selection twice or more and just pushing and pushing the same view controller onto the stack


Try...

  • Create BOOL value, something like BOOL isSelectionActive;

  • Then in - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath set the isSelectionActive=TRUE;-

  • Then, in - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath return nil if isSelectionActive is TRUE, otherwise return the indexPath.

  • Before dismissing the pushed view. set isSelectionActive=False. You can do this by passing in a reference to the viewController that is pushing the new view. And setting isSelectionActive=FALSE before dismissing the view.

or

  • You can set isSelectionActive = TRUE in viewWillAppear, which will get called when you dismiss the pushed view.


That is very little information. :) But you could

a) check if the view controller is already there

b) suppress user selecting the same selection (from the information you supplied it is impossible to tell you how you should go about that)

0

精彩评论

暂无评论...
验证码 换一张
取 消