Label of UIButton appears intermittently inside a UITableView - iphone

I have a UITableView with some data. One of controls is a UIButton, with a label assigned. So, in rare cases, when I push the UITableView screen, the buttons appears without label. After I scroll the UITableView or rotate the device, the label appears.
I put a NSLog entry inside the drawRect method. And It's not called in some cases.
Some advices?
Thanks

i found same problems that some methods rarely not called. make sure delegate is properly set and then check the result

After analyzing my code I saw some characteristic that caused the problem. The process of construction of my screen was occurring in a different thread of the events thread. So, I fixed this and everything is fine now.
Thanks.

Related

iPhone: Best way to handle 400 UILabels in UIScrollview

I've been working on a crossword app for a while. The actual game runs in a UIScrollview, because the player should be able to scroll, zoom and pan.
To the UIScrollview i added a UITapGestureRecognizer that handles the touch-event, and calculates where the player touched. So far so good.
Afterwards I added about 400 UILabels to the UIScrollview. Each of them are "empty" until the player presses a button on the keyboard. My problem is that when i add these labels the whole UIScrollview become very slow and laggy in scrolling etc.
As the user guesses the right words green tiles will become visible. The tiles are loaded in as UIImageViews. This reduces the performance again.
I have looked at DTGridView, but I've got no luck with it.
Can you please help me out and try to guide me in the right direction?
i think you should implement the UIScrollview method drawRect you self instead of add 400 UILabel in it
you can set a NSArray contains 400 objects called "label";
when user pressed the button, you should calc the postion & test of the "label" &decide which "label" should display in the scrollview in current offset .
add 400 UILabels in one UIScrollview may cause the memory problem;
You need to use recycled label in your scrollview. That will improve the performance. To know how to reuse/recycle subviews in UIScrollView please check Apple WWDC videos on UIScrollView. WWDC 2010 Sample Code . Also check UIScrollView Class Refference UIScrollView Class Reference
You can get help from this link Creating Circular and Infinite UIScrollViews
I've been playing with this for the past while/days even. Using various related answers. But eventually I used instruments and a bit of commenting to see what was slow.
I remember someone saying layoutSubviews slows things when you addSubviews, so I took my "Local" code out of there. But nothing sped up.
So when using a breakpoint during my addSubview routine, I noticed the iOS system was actually in a superview's layout calls (navigationCtrlr) during viewDidLoad.
I introduced a 0.1 second delay before adding subviews and bam! I recommend dispatch_async to prevent crashes from race conditions, but that's another subject.
In short, it might be in LayoutSubviews even if you don't think you are there.

Why won't UITableView 'Auto-scroll' when editing UITextField (in UITableViewCell)? (iPhone)

I have created a UITableView that is of type UITableViewStyleGrouped. I have then created several different sections with a few rows in each. Within each of these rows I have created a custom UITableViewCell that contains a UITextField. I also have one UITableViewCell that contains a UITextView.
I have also implemented a UIToolbar that appears on top of the UIKeyboard that allows the user to move through the UITextField's by pressing previous or next.
The issue I'm having is two-fold:
I need the UITableView to scroll so that when the next UITextField (or UITextView) becomes the first responder it is visible (even with the keyboard being displayed).
When a UITextField (or UITextView) is selected (without using the previous and next buttons) is should adjust so that the field is visible above the keyboard.
I have looked around at lots of different tutorials however none of them have resolved my issue. Any help you could offer would be hugely appreciated.
ADDITIONAL INFO:
I'm 100% certain that my app used to do all of the above automatically, however I seems to have stopped doing it now and I don't understand why. Is there a reason why this may of happened? Is there some function or something that I may have changed that would destroy this behaviour?
Probably no use to original poster now, but those having an issue like this where it once did work and then stopped...
check you don't have a:
- (void)viewWillAppear:(BOOL)animated
in your UITableViewController subclass!!!
using viewWillAppear in a UITableViewController breaks the "automagic tableView scrolling up when keyboard appears" behaviour.
I only found this by comparing laboriously an old version of a project where it did work with my latest source where it had stopped working.
Check out TaggedLocations sample code from apple. It does the same thing without any extra manipulation.
The key is that your viewcontrollers are following the standard. i.e you are NOT having container viewcontrollers such as UINavigationController within UIViewController.
You have to update tableview Frame yourself programatically...
and i am 100% sure that if you are 100% certain that your app used to do all of the above automatically ...than it is not your app.
Check the docs..here is the link
https://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/ManageTextFieldTextViews/ManageTextFieldTextViews.html#//apple_ref/doc/uid/TP40009542-CH10-SW1
You will have to register for keyboard notifications..and then update your tableview frame.
And for next and previous.. you have to programmatically check which textfield became active..and then set the frame accordingly.

UIScrollView - how to get rid of delay before scrolling?

I'm using a UIScrollView to display a custom UIView. When the user drags a finger across the UIScrollView, there is a noticeable delay before the display begins updating. If the user keeps touching the screen, the UIScrollView becomes very responsive after a short time. Subsequent attempts to scroll result in the same initial delay, followed by high responsiveness. This delay seriously affects the usability of the view and I would like to get rid of it.
In a test project I have written to try to get to the bottom of this issue, I have only been able to partially replicate the behaviour. The first time that the user scrolls is exactly the same - however any subsequent attempts to scroll are responsive straight away.
I have tried both setting delaysContentTouches = NO and subclassing UIScrollView so that touchesShouldBegin returns NO as suggested in multiple places online, but neither has worked.
I'm using MonoTouch on iOS 4.3, but Objective-C answers are fine. I would post code to help illustrate the issue, but since I have been unable to narrow down the problem this would be well over 1000 lines. Hopefully this is enough info to get a solution.
Does anyone know what might be causing this delay, and how I can get rid of it?
Some general suggestions for improving scrolling performance.
Have your scrolling views rasterize offscreen:
myView.layer.shouldRasterize = YES;
Set that property for each sub-view on the scrollview - do not set it for the children of those sub-views or you just eat up memory that way.
If your scrolling views do not need compositing, make sure you turn that blending off:
myView.opaque = YES;
Test using the simulator by leveraging these two features that appear on the Debug menu of the iOS Simulator:
Color Off-screen Rendered
Color Blended Layers
If that doesn't address your problem, and you have implemented UIScrollViewDelegate, double-check to make sure you are not doing anything time consuming in those methods - for example, based on your description, you might be doing something in scrollViewDidScroll, scrollViewWillBeginDragging, or scrollViewWillBeginZooming and if you are, optimize that so it happens before scrolling even begins. Also, make sure you're not doing anything in touchesBegan.
I suspect what is happening is there is some kind of interaction enabled in the content of your scroll view.
The system does not know if the initial touch down is going to be a tap on one of the subviews or a drag on the scroll view, therefore is causing a delay while it waits to see if you are going to lift your finger.
What are the subviews of the UIScroll view?
As an experiment set all the subviews of the UIScrollView to have userInteractionEnabled = NO, this will not be what you want, but its just a test. Is should scroll fine after this, otherwise I am wrong.

custom uitablviewcell does not call didSelectRowAtIndexPath in the controller

I have a custom UITableViewCell completely written in code (no IB), it has an accessory button that simply calls didSelectRowAtIndexPath on the table view, and it works correctly and the method is called without problems.
However, when I tap on the cell itself (not on the accessory view) nothing being called, why ?
EDIT: the code is huge to put here ... however, the custom cell contains a ton of labels, couple images and scroll view ...
This is a shot in the dark, but if each cell has many different objects on it (i.e. images, labels, etc) then it may not be working because those objects are what the user is hitting when they try to click a cell. Does the cell turn blue (indicate selection) at all? If not, try hiding/removing those objects for now and see if it works.
If that is the case, then what you may want to do is create an invisible cell or button that sits on top of the other objects and calls didSelectRowAtIndexPath from behind the scenes.
This should solve your problem:
Raise selection event (didSelectRowAtIndexPath) when subview of UITableViewCell is tapped
Try setting your view's userInteractionEnabled property to NO.
This will make it ignore all touch events, and then the views under it will be able to catch these events. - Felipe Sabino
I'd partially answer my question: the wide scroll view is preventing the cell from calling didSelectRowAtIndexPath, removing the scrollView will solve the problem, however, I want to call this method with the existence of the scrollView ... anyone got ideas would be highly appreciated ...
You must post your code to understand what have you done...You have to check out this example to understand whether your code is correct or not...
http://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-a-custom-accessory-view-for-your-uitableview-in-iphone/

Uiwebview shouldloadrequest not getting called sometimes

I am using nine webviews inside a scrollview to get an infinte scrolling effect. I am loading image map inside each webviews. Now the problem is webviews are not responding sometimes for the touches, when it is a hard-touch(touch and hold). I am getting this issue when more than one webviews are visible. I have set the delegate for every webviews, I dont know why this happening.
I am loosing the selection while holding it, its grey color dissappears. This issue I am getting only in 3.2iPad device.
I need to get the shouldStartLoadWithRequest method called while each press. what i need to do?
thanks in advance,
You have to read the Apple document for UIWebview, they are clearly saying,"Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled."
check this link:- http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html
But I also do adding UIWebview to UIScrollview, But in my case the frame of a webview is same as the frame of scrollview. In this case the touchevent is properly detected.
And One issue I found in this case we can get UITapGestureRecognizer from that Uiwebviews...