Saturday, July 23, 2011

Random questions in iOS

1) How to disable UIWebView scrolling ?

Ans: UIWebView is derived from UIScrollView. Therefor we must be able to disable the scrolling of UIWebView.

Here is the working code:
UIScrollView *scrollView=[[webView subViewslastObject];
[scrollView setScrollingEnabled: NO];

2) How to check the iOS version of device ?

Ans: This is a very frequent scenario where you need to check which version of iOS the target device is running.

The very best solution that Apple recommends is,

  • if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
  • // Load resources for iOS 6.1 or earlier
  • } else {
  • // Load resources for iOS 7 or later
  • }

No comments:

Post a Comment