3

As soon as "self.navigationController pushviewcontroller:vc animated:YES" is executed, my CPU goes to 100%. I searched for the same issue on Stack Overflow and found that UITextView might be creating such problem. I removed UITextView and it started working fine. What is it to do with UITextView? What can I do to use it?

I have IB of UITextView

@property(nonatomic ,retain) IBOutlet UITextView *txtvwMessage;

Also I have UITextView's delegate Outlet to my View controller class.

Abhinav
  • 37,684
  • 43
  • 191
  • 309
Milan Gupta
  • 1,181
  • 8
  • 21
  • Have you tried pausing the app and seeing what it's doing (hint: look at the call stack)? – Droppy Oct 06 '15 at 07:39
  • 2
    Found the solution. It is a bug of iOS 9.0. UITextView should have minimum 10 characters by default. I entered more characters in storyboard UItextView -> Property -> text. Started working like charm. Reference : http://stackoverflow.com/questions/32611789/uitextview-with-text-less-than-10-characters-hangs-ios-9 – Milan Gupta Oct 06 '15 at 08:50

2 Answers2

0

My advise to you is to profile your application using Instruments to see what method is using the majority of CPU time. You can then trace back on method stack trace to come to a conclusion. You can use Time Profiler. It would be hard to tell otherwise with such small information!

Abhinav
  • 37,684
  • 43
  • 191
  • 309
-1

Try not to retain the text view. Use the assign/weak as follows:-

@property(nonatomic ,assign) IBOutlet UITextView *txtvwMessage;

OR

@property(nonatomic ,weak) IBOutlet UITextView *txtvwMessage;

Now check the CPU percentage usage.

pkc456
  • 8,350
  • 38
  • 53
  • 109
  • 4
    How does that cause high CPU usage? – Droppy Oct 06 '15 at 07:40
  • I found the correct answer. UITextView should have minimum 10 characters by default (bug of iOS 9.0) Reference : stackoverflow.com/questions/32611789/ – pkc456 Oct 06 '15 at 12:57
  • Yeah the OP said the same thing 4 hours ago. You should delete your incorrect answer. – Droppy Oct 06 '15 at 13:00
  • I think other people must learn from my mistake and it prevent to publish wrong answers to the same question. I agree that my answer was incorrect, but if I delete it then other person may make the same faulty thing to this question. So let it be. If it still sounds weird, then I will delete it. – pkc456 Oct 06 '15 at 13:03