Monday, November 30, 2009

John Muchow: UIAlertView and Landscape Mode

Itt van az egesz cikk, de a lenyeget idemasolom:

Show Alerts in Landscape Mode

To fix this, all you need to do is add the following line of code – I placed this in the applicationDidFinishLaunching method:

// Required so UIAlertView shows in the correct orientation in landscape mode

[application setStatusBarOrientation:

UIInterfaceOrientationLandscapeRight animated:NO];


Thursday, November 26, 2009

MPSwipableView, MPFullScreenVideoOverlay

Amikor az MPMoviePlayerController csinal egy sajat window-t ami a keyWindow lesz, akkor ennek egy subView-ja van es az egy MPSwipableView amirol nem talaltam sok mindent, csak annyit, hogy UIView-bol oroklodott es az MPFullScreenVideoOverlay az o leszarmazottja, de ezek nem dokumentalt view-k.

Tuesday, November 24, 2009

MPMoviePlayerController Done button-janak letakarasa.

Eloszor is az [MPMoviePlayerController Play] csinal egy sajat window-t, tehat a UIButton-t amivel le fogjuk takarni a Done buttont azt a keyWindowChanged notification-ben kell letrehozni.

Azt gondolnank, hogy egy akkora gombot kell rarakni mint amekkoranak ot latjuk, de valojaban a minimalis biztos megoldas ha a UIButton frame-je (256, 5, 43, 49)-es frame lesz. Ez igy fog kinezni ha lathatova tesszuk:

Meg kozelebbrol igy nez ki:
Lathato, hogy a szurke sav tetjebol igy nincsen letarkva egy pixelnyi ami mar nem baj, de ha egy pixellel alacsonyabb lenne a takaras, akkor mar valahova C betu aljara bokve megkapna a Done button az event-et.
Eleg furcsa igy ez a (256, 5, 43, 49) CGRect. Szebb lenne mondjuk egy (255, 5, 45, 50)-es, ami szinten jo. A lenyeg, hogy a (256, 5) es a (299, 54) pontok es az alltaluk hatarolt resz le legyen takarva. Legalabbis 3.1.2-es OS-nel igy lehet letararni a Done button-t.
Erdekes egyebkent, hogy ha nincsn letakrava akkor nyugodtan lehet mondjuk a Carrier feliratot is nyomni a Done button folott ugy is megkapja a Done button az eventet, ugyanakkor nem kell odaig letakarni. Nem tudom hogy van ez a gomboknal, de nagyon ugy tunik, hogy nem pont azt a reszt fedik le ami latszik beloluk, hanem valamivel tobbet.

Friday, November 20, 2009

overlay View az MPMoviePlayerController-en

Az [MPMoviePlayerController play] utan csinal egy sajat window-t ami a sharedApplication keyWindow-ja lesz, azaz ezen kell meghvini az addSubview-t, viszont fontos, hogy megvarjuk mire valoban ez lesz a keyWindow. Ezt ugy tehetjuk meg, hogy a play elott feliratkozunk a UIWindowDidBecomeKeyNotification notification-re es abban adjuk hozza a sajat UIView-(i)nkat a keyWindow-hoz (ami a [notfication object]).

Wednesday, November 18, 2009

awakeFromNib

Inkabb bemasolom ide az egeszet:

Prepares the receiver for service after it has been loaded from an Interface Builder archive, or nib file.

- (void)awakeFromNib

Discussion

The nib-loading infrastructure sends an awakeFromNib message to each object recreated from a nib archive, but only after all the objects in the archive have been loaded and initialized. When an object receives an awakeFromNib message, it is guaranteed to have all its outlet and action connections already established.

You must call the super implementation of awakeFromNib to give parent classes the opportunity to perform any additional initialization they require. Although the default implementation of this method does nothing, many UIKit classes provide non-empty implementations. You may call the super implementation at any point during your own awakeFromNib method.

Note: During Interface Builder’s test mode, this message is also sent to objects instantiated from loaded Interface Builder plug-ins. Because plug-ins link against the framework containing the object definition code, Interface Builder is able to call their awakeFromNib method when present. The same is not true for custom objects that you create for your Xcode projects. Interface Builder knows only about the defined outlets and actions of those objects; it does not have access to the actual code for them.

During the instantiation process, each object in the archive is unarchived and then initialized with the method befitting its type. Objects that conform to the NSCoding protocol (including all subclasses of UIView and UIViewController) are initialized using their initWithCoder: method. All objects that do not conform to the NSCoding protocol are initialized using their initmethod. After all objects have been instantiated and initialized, the nib-loading code reestablishes the outlet and action connections for all of those objects. It then calls the awakeFromNibmethod of the objects. For more detailed information about the steps followed during the nib-loading process, see Nib Files and Cocoa in Resource Programming Guide.

Important: Because the order in which objects are instantiated from an archive is not guaranteed, your initialization methods should not send messages to other objects in the hierarchy. Messages to other objects can be sent safely from within an awakeFromNib method.

Typically, you implement awakeFromNib for objects that require additional set up that cannot be done at design time. For example, you might use this method to customize the default configuration of any controls to match user preferences or the values in other controls. You might also use it to restore individual controls to some previous state of your application.


networkActivityIndicatorVisible

A UIApplication class-ban van.

A Boolean value that turns an indicator of network activity on or off.

Hogyan merjuk az eltelt idot

Aaron Hillegass: How to Time

#import 

uint64_t start = mach_absolute_time();

// do stuff to be timed

uint64_t end = mach_absolute_time();
uint64_t elapsed = end - start;

mach_timebase_info_data_t info;
if (mach_timebase_info (&info) != KERN_SUCCESS) {
    printf ("mach_timebase_info failed\n");
}

uint64_t nanosecs = elapsed * info.numer / info.denom;
uint64_t millisecs = nanosecs / 1000000;

Tuesday, November 17, 2009

Status bar eltuntetese

Az Interface Builder-ben hiaba allitjuk none-ra a Status Bar-t (320 x 20 px), az attol meg latszik.

Igy kell eltuntetni:

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];


Ez viszont onmagaban meg nem eleg, mert a View teteje ugyan felkerul a Status bar helyere, de letakarja egy darab a Root View Controllerbol. Akkor mukodik jol, ha az xx-Info.plist-ben felvesszuk a "Status bar is initally hidden" kulcsot es kipipaljuk. Ezutan persze ahol latni szeretnenk a Status bart, ott kulon meg kell adni a fenti hivassal, hogy NE legyen hidden, de ahol azt adjuk meg, hogy legyen hidden ott tenyleg az lesz.

A masik lehetoseg, ha nem nyulunk az Info.plist-hez, hanem az AppDelegate-ben az applicationDidFinishLaunching-ban allitjuk be YES-re mielott a window-hoz hozzaadnank a Sub View-t. Ezutan akar vissza is allithatjuk NO-ra es csak ott valtoztatunk rajta ahol kell.

A lenyeg, hogy miutan egy Sub View-t mar hozzaadtunk a window-hoz, akkor mar hiaba rejtjuk el a Status Bar-t, ha elotte nem tettuk meg akkor hibas lesz. Ez valami bug lehet, a 3.1.2-ben amit gondolom kesobb majd javitanak.

Wednesday, November 11, 2009

Thumbnail keszitese

Itt van egy fuggveny ami csinal egy thumbnailt egy UIImage-hez anelkul, hogy torzitana. Ha a thumbnail meretaranya kulonbozik az eredeti kepetol, akkor levag a tetejebol-aljabol vagy az oldalaibol.

Categories

Ahogy John Muchow irja:
"As an alternative to subclassing, Objective-C categories provide a means to add methods to a class. What’s intriguing, is that any methods that you add through a category become part of the class definition, so to speak. In other words, if you add a method to the NSString class, any instance, or subclass, of NSString will have access to that method.

Defining a category is identical to defining the interface for a class, with one small exception: you add a category name inside a set of parenthesis after the interface declaration..."

Categories and Extensions leiras az iPhone OS Reference Libraryban

Monday, November 9, 2009

Milyen warningokat erdemes bekapcsolni

Peter Hosey irasa.

Sunday, November 8, 2009

How To Get two or more different versions of the same app on your iphone.

via Google Groups

1. Right click on the project
2. Select Get Info menu
3. Find Product Name in the right column
4. Change this property as you like. E.g. build20091107
5. Build your app
6. Upload app on the iphone
7. Get the icon with the text build20091107
8. Go ahead and repeat all steps once again but set another build
number in the step 4. E.g. build20091108
9. Get two different apps on your iphone.

Thursday, November 5, 2009

UIActionSheet

A dokumetacio es egy rovid tutorial.

Monday, November 2, 2009

Button (vagy barmi mas) UITableView ala

Ugy szerettem volna gombokat elhelyezni egy UITableView ala, hogy azok egyutt scrollozzanak. Erre itt van egy megoldas: A tableView:viewForFooterInSection-ben kell visszaadni egy olyan UIView-t amiben letrehozunk egy UIButton-t, vagy amit szeretnenk. Fontos, hogy a tableView:heightForFooterInSection-ben olyan magassagot allitsunk be, amibe belefer majd a UIView-nk. Azt nem emlitik, de fontos lehet, hogy a tableView:viewForFooterInSection a UITableViewDelegate-ben van.
Ez meg itt egy masik pelda ugyenrre, csak UIButton helyett UISwitch.

Update: Multkor fejbol csinaltam es elfelejtettem, a tableView:heightForFooterInSection-t beallitani. Enelkul is lattam a footer view-ba pakolt gombokat, csak megnyomni nem lehetett oket.