Showing posts with label Harsh Thaker. Show all posts
Showing posts with label Harsh Thaker. Show all posts

Monday, 5 August 2013

Difference between #import and #include in Objective C code ? iPhone/ XCode programming

#import and #include are like same. They perform the similar thing but the only difference is that #import makes sure that the same header file hasn't included again.

It is preferred to write #import over #include in your code. 

- Reference Learning from iOS Developer Library

Saturday, 13 April 2013

Cannot use super because it is a root class error in Xcode project !



Getting an error "cannot use super because it is a root class" and wasn't able to find the proper solution. After a while found that have misplaced the name so "self" calling was not working.

This error may appear either you haven't written @interface "" @end or misplaced the name of it or written a different name after "@implementation"

e.g. in above image, as I was working on CoRoViewThree_iPad, when I replaced "Four" with "Three" and similarly Three instead of Two in @implementation, the error resolved.


Such kind of error mostly occurs when we copy the codes of different view controllers and forget to change the names.




How to make an invisible button in iOS App xib ? Hidden Vs. Custom type

I was developing an app where I needed to replace the existing buttons with the invisible ones, means in the background I've set my useful image that replaces buttons.

There were some sound play events on button touch up inside. I firstly, tried making the buttons hidden by ticking one of the properties of making a button hidden. 


The problem I faced was that on running the app the sounds were not being played. Tried a little to resolve it and the solution was :

* To select the button type to custom, that makes the button disappear and works like hidden. So now, sounds got played and it worked !


And in order to show the button getting pressed, tick the option of "shows touch on highlight"

Sunday, 31 March 2013

iOS 6 views/layout backward compatibility resolution

How to solve the problem of layout of views when creating app supported for iOS 6.1 and the previous version of it ?

I updated my xcode to version 4.6 ! The first problem I faced was the layout issue with the screens. As I wanted to develop app that supports not only iOS 6.1 but also with the backward compatibility with the previous versions.

After I designed the screen, I ran it on 6.1 simulator, it worked well. Then I chose the hardware iPhone ratina 3.5 and it got weird. Images got misplaced and didn't work well.

I tried to have a look on many forums but couldn't find the easy resolution, so I spent some time and was changing properties and was testing. 

The solution is :

  • Go to the size inspector
  • See the left box ?
  • Set Origin to the centre 
  • Don't use auto layout, it is for vertical and horizontal view settings / Make it unchecked   
  • If it's just strict portrait then go this way.
If you have more queries, you can write me here or contact me on facebook.com/harshsthaker