iOS: Using modal pageFlip makes strange cell animation in UITableViewController - ios

I wanted to show a Settings view, so I figured I could use the pageCurl modal style. I have a UIViewController that I am presenting from:
Settings *settings = [[[Settings alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
settings.view.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
settings.modalTransitionStyle = UIModalTransitionStylePartialCurl;
settings.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:settings animated:YES];
When the page curls, to reveal my UITableViewController below, the cells subviews (labels and accessory views) seem to animate into position, which looks horrible:
The strange thing is, is that the animation never happens to the top cell in a section. This does not happen with other modalTransitionStyle's so I am wondering why this could be happening. It is really becoming frustrating because I cannot figure out how to stop this from happening.
Ideas?

If you set the autoResizingMask property of the tableView to UIViewAutoresizingNone, I think this won't happen. This may be a little bug in the page curl animation.

I've noticed that the direction of this weird animation (which also happens to UIButtons), depends on the Alignment chosen in the Control section of the object's Attributes inspector (in Interface Builder). I've been tinkering with all attributes all evening and have found no solution yet. :(
Edit: so, I had three UIButton in my view (and one UIPickerView) that where doing this weird behavior at the same time. I created a property linking to ONE of the UIButtons. Then, in the viewDidLoad of this view's controller I added the following line:
_firstAffectedButton.titleLabel.autoresizingMask = UIViewAutoresizingNone;
And that fixed it for me, for all the buttons and the picker!! :? Weird, right?
Can anyone explain why this is working? I have the feeling I'm doing something stupid to fix this, but I can't see what it is.
Edit 2: Turns out there was a better and cleaner solution to this problem. See this post.

Related

TableView didSelectRowAtIndexPath not called

So I have added a UIUITableView to a UIViewController. I can't use a UITableViewController for reasons I don't need to explain since it will be unnecessary information. Anyway, I have set the delegate, and the data source to this viewController. I've added the delegate and datasource protocols as well. The cells are populated correctly, so the datasource is working fine. I can also scroll so it all works fine.
However, I can't get the didSelectRowAtIndexPath to trigger. It SHOULD trigger, but doesn't. I've read and a lot of issues with this can be correlated to a UIGestureRecognizer, but I haven't implemented one. I also use the standard UITableView, so not a custom made one.
If I long press the cells (3-4 sec) then it gets triggered as it's supposed to. This suggests that there is some issue with another view or something absorbing the tap gesture, which I have no control over. How would I solve this?
No, it's not didDeselectRowAtIndexPath.
Yes all delegates and datasources are correct, since I can get the delegates/sources to trigger.
Yes, Single Selection is set on the TableView in the inspector.
Yes, everything has user interaction enabled.
If I just copy the code over to a UITableViewController it will work just fine, but right now that is not an option, I'm afraid. Anyone got any ideas on how to solve this? Most people who've had this issue has either had the issues in the list above, or added a UIGesture on top of the UITableView - I haven't.
I want to start by saying that I appreciate all the answers here provided, it gave me a lot of things to try out so I learned a lot - thanks! None of your suggestions worked, but simply because I'm a complete idiot. I said in the post that I did NOT implement a UIGestureRecognizerwhich I didn't...in that class, but in its super class. So I DID in fact implement it, but in a class that this ViewController was a subclass off. The only reason I didn't remember it was because I haven't looked at that super class for weeks.
Someone did suggest it in the comments that I should check for it, and I did and I was already certain I didn't implement one, so I quickly dismissed it. But now, after about 4 hours of debugging and recreating the project, adding things one by one, I eventually realized that the only thing that differed at this point was the Super Class, and the first piece of code I see when I open the file up was a GestureRecognizer...
So keep this in mind in the future everyone - I know I will. Thanks again for the help!
Sincerely,
The complete idiot.
Make sure you don't add any controller in that cell, which covers the entire cell and also the user interaction of that controller is enabled.
Due to that controller's user interaction enabled the tap action is taken by that controller and when you long press that cell, that cell will receive your tap.
Example :
UIView *_view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _cellWidth, _cellHeight)];
[_view setUserInteractionEnabled:YES];
[cell.contentView addSubview:_view];
In the above case that view got your tap instated of the cell.

Changing the zPosition of searchResultsTableView

I have a UISearchBar working to dynamically show matching results from a list, but having a nightmare trying to stop the searchResultsTableView from obscuring the resultant UIView, which animates in from the right, when the result is tapped.
The magenta view, (including its shadow subview) and the solid black view should be above the list.
I've tried…
self.searchDisplayController.searchResultsTableView.layer.zPosition = 0;
recipeMeasuresView.layer.zPosition = 1;
recipeListView.layer.zPosition = 2;
…but it's messing up the gestures attached still not displaying the views in the correct order. I've also tried…
[self.view sendSubviewToBack:_searchBar];
[ingredientListView bringSubviewToFront:ingredientListView];
…still no joy. Incidently, I'm also adding – amongst other things – [_searchBar resignFirstResponder]; to my
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
I'm very much an objective-C newbie so all help greatly appreciated.
In case anybody else stumbles across this with similar problems it seems that the issue is due to the searchDisplayController adding it's own view(s) at the top of the stack, therefore obscuring anything that was added to the storyboard.
There would be no way to push anything up or down to change the order because the searchDisplayResultsTable was being added by a different view controller.
The solution I used was to add the views that were being hidden programatically, meaning I could add them as subviews to different parent views depending on what was happening. Probably not the best solution but it does appear to work.

Adding and Removing UIView From Springboard

I am developing a little MS tweak that adds a view on the Springboard. I want it to be constantly updated so I called it into the
- (void)showSpringBoardStatusBar
Then I create and add the view using this:
[[UIApplication sharedApplication].keyWindow addSubview:view1];
Is this the right way?
But the problem is this view uses a low alpha level to be transparent and every time the view is updated by the showSpringBoardstatus bar another UIView is added onto of it eventually just making the view solid. This also is uneconomical in terms of memory. so then I went back an added what I thought would remove the code:
view1 = nil;
[view1 removeFromSuperview];
But it seems like this doesn't make a difference as it is still there and nothing changes.
I have been searching for the last few days for anything to help me with this but got nothing out of it. All I can think of is that I can't remove an added subview from a key window like I would from a normal view or I just don't how to do it correctly.
Any help would be appreciated. Thank you.
Setting view1 to nil and than calling "removeFromSuperView" might be a bad idea. How about adding the view only once, keeping a reference and updating this reference constantly without adding it to keyWindow again?

iOS subview not forwarding touches.

I have tried this a few different ways but none of them seem to work. I have a UIView subclass that has some buttons in it. I tried adding the subview to my ViewControllers however it will not respond to touches unless I set it to "initWithFrame:self.view.frame" but then it takes All of the touches and does not pass them to the view controller. I also tried adding it directly to the window so it's on top of all of the view however I have the same issue, either it will not accept touches or it takes them all.
here is how I add it when it takes all touches for itself and does not pass them on.
ControlView *cont = [[ControlView alloc]initWithFrame:self.window.frame];
[self.window addSubview:cont];
I'm so confused as to how to fix this and I have a lot more important tasks to work on but I have been stuck for two days with this stupid subview/touch issue.
How are you handling touches? UIGestureRecognizer?
You should make sure that your uiview subclass has userInteractionEnabled = YES. That's the default but maybe it got turned off somewhere along the line.

disable scrolling in a UITableView (iPhone SDK 3.0)

I'm trying to disable scrolling in a UITableView when editing a UITextField embedded in a UITableViewCell.
This is just to prevent the cell from being scrolled out of sight when edited (and also to avoid some related cell "Recycling" problems).
While googling around I've seen that somebody suggested the obvious:
tableView.scrollEnabled = NO:
or even
tableView.userInteractionEnabled = NO;
This does not work though (at least for me... iPhone SDK 3.0, tried on simulator)
I set these properties to NO, I even check by logging that the properties are set to NO, but the UITableView keeps on responding normally to touch events.
And it also happily scrolls.
I wouldn't be that worried if somebody on the net were not claiming that this actually works.
Am I missing something?
Or is the only alternative subclassing UITableView to make a functionality available in its superclass (UIScrollView) work again?
Did you try using
self.tableView.scrollEnabled = NO;?
I've often tried that code from the web didn't work, simply because of a lack of the prefix self. I just tried this out without a problem.
I don't know if this work when turning it on and off dynamically. It does at least work for permanent settings when initializing the object...
If you're using UITableViewController, you also have a tableView property, with no casting needed. This works for me:
self.tableView.scrollEnabled = NO;
Let me know if that works for you.
Did you try on storyboard unselect scrolling enabled?
I tried:
[(UIScrollView*)[self view] setScrollingEnabled:NO];
and it worked ([self view] is my view of the current view controller, i.e., a UITableView).
The thing is, I get a warning:
'UIScrollView' may not respond to '-setScrollingEnabled:'
In all honesty, the property is "scrollEnabled", but it works nonetheless with the aforementioned code!
So, the "right" way to do things, should be:
[(UIScrollView*)[self view] setScrollEnabled:NO];
Why it also works the other way, is confusing me...
None of these answers worked in my case. Table view kept scrolling ever though every scrollView was disabled.
Finally, I've found solution in here, claiming that UITableViewController does this "for me" whenever keyboard hides the UITextView being edit.
Solution is to inherit from UIViewController instead of UITableViewController and implement the required table functionality myself.
if you want to scroll only if its content is not visible then set:
yourTableview.alwaysBounceVertical = NO;
Here if your content is visible then your tableview will not scroll

Resources