setneedsdisplay

App crashes on call to setNeedsDisplay for custom button

痞子三分冷 提交于 2020-01-17 15:29:07
问题 I've custom button, app crashes randomly on call to setNeedsDisplay . How to fix this crash? class MyVC: UIViewController { @IBOutlet weak var customButton: CustomButton! override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) self.customButton.setNeedsDisplay() // Random crash here } } class CustomButton: UIButton { // .... override func setNeedsDisplay() { self.imageEdgeInsets =

iOS: How to get background thread to redraw view on main thread

守給你的承諾、 提交于 2020-01-02 12:38:06
问题 My application will query a database 50 times and will then react accordingly by adding the right UIImageView to another UIImageView, which I then want the application to display immediately at each loop. Alas, after many nights I have failed to get it to work. The application will not immediately display the UIImageView. Having said that, when I zoom in or zoom out during mid loop the UIImageViews will appear! I must be missing something... So far every code works except the last part

SetNeedsDisplay not working

一笑奈何 提交于 2019-12-21 04:09:00
问题 I saw many threads related to this issue, but none addresses my case (I think). My case should be simple, I have a Custom UIView in my controller, from my controller, I use the [ self.myView setNeedsDisplay ] and it works perfectly. I'm having problems when Im trying to call this from inside of the UIView itself...I have a notification being sent from another class, and it is being received by my View (this works) with the information it passes, I update internal properties of this view and

reload/refresh subViews - setNeedsDisplay doesnt work

安稳与你 提交于 2019-12-18 04:23:42
问题 i have trouble with setNeedsDisplay. I have an UIView with a lot of sub UIViews, created in Inteface Builder. I have also an Button with IBAction. In this IBAction i want to redraw/reload all UIViews (or all UIElements, like UILabel, UIWebView and so on..) I am doing this, which doesn't work for me, dont know why.. : //redraw the UIViews [self.view_card_0 setNeedsDisplay]; [self.view_card_1 setNeedsDisplay]; [self.view_card_stapel setNeedsDisplay]; //other UI Elements [self.webView_0

Having UIView drawRect occur in a background thread

为君一笑 提交于 2019-12-17 19:51:39
问题 I would like to have a UIView subclass that implements a method similar to setNeedsDisplay , except that redrawing (i.e., that would usually be called via drawRect: ) will occur in a background thread sometime soonish, rather than at the end of the current update cycle. It might be called setNeedsAsynchronousDisplay . Or the existing setNeedsDisplay could get hijacked and not cause redraw at the end of the cycle, or whatever, as long as it lets the redraw not happen on the main thread

Button to trigger drawRect to redraw a view

北城以北 提交于 2019-12-11 11:39:18
问题 I have a VC with a subview. At the subview level I have a button. I want the button to result in the view being updated. The IBAction code is in the VC. All it currently does is toggle a BOOL value. Back in the subview drawRect: method is the code that tests the BOOL and changes the view accordingly. My observation is that when the button is pressed, the IBAction code runs, toggles the BOOL , but the drawRect: method doesn't get called. I tried calling drawRect manually (not good practice and

How to redraw my view in SWIFT?

青春壹個敷衍的年華 提交于 2019-12-11 09:46:52
问题 On my iPad app, I have a UIViewController with a button that open a modalView. @IBAction func showPostCommentViewController(sender: AnyObject){ let modalView = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("PostCommentViewController") as! PostCommentViewController modalView.modalTransitionStyle = UIModalTransitionStyle.CoverVertical modalView.modalPresentationStyle = UIModalPresentationStyle.FormSheet modalView.delegate=self self.presentViewController

iOS: How to “Refresh” a UIViewController after Popping its Child UIViewController?

风流意气都作罢 提交于 2019-12-09 21:32:44
问题 In my app I'm using UINavigationController. I have a "parent" UIViewController and a "child" UIViewController running on the stack. The user can do some settings on the child that are later on suppose to affect the parent. I use NSUserDefaults to save and retrieve the data, and it seems to be working fine according to the NSLog. What I'm not clear about is how am I supposed to "refresh" the data once I come back from the child. Let me be more specific: In the child there is a "Back" button

Set UIView backgroundColor with drawRect:

冷暖自知 提交于 2019-12-08 10:26:37
问题 I am trying to set a custom UIView class's background color. The class also does quartz drawing in the drawRect: method. Since background color change does not take place until the next redraw of the view, I change the UIView's backgroundColor property before calling setNeedsDisplay . I have set a UIActivityIndicatorView to animate while the view is redrawing. self.backgroundColor = theColor; [indicator startAnimating]; [self performSelectorInBackground:@selector(setNeedsDisplay) withObject

UIView setNeedsDisplay Not on main thread?

耗尽温柔 提交于 2019-12-08 09:09:50
问题 In my iPhone application, I have a secondary thread that I have made for performing tasks in the background, and every few milliseconds, the view must be updated (not from the main thread). I have tried the following code in my UIView subclass: [self performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO]; That works great on the simulator, however, on my device, it is very laggy. The only thing I can think of is that the main thread is bogged up with the usual