Wednesday, December 8, 2010

popViewController landscape modban fentrol lefele

Az volt a baj, hogy csak a UINavigatonController-ben adott vissza a shouldAutorotateToInterfaceOrientation YES-t. Igy ugyan a pushViewController-rel megnyitott ViewControllerek is forogtak, de ha azokorol visszaleptem (popViewControllerAnimated) landscape modban, akkor nem rendesen jobbra csuszott ki a ViewController, hanem fentrol lefele.

Az a megoldas, hogy nem eleg a UINavigationControlleren megadni a shouldAutorotateToInterfaceOrientation-t, hanem a tobbi ViewCotrolleren is meg kell ezt tenni. (Legalabbis azokon, amikre vissza fougunk lepni popViewControllerAnimated segitsegevel.)

Monday, December 6, 2010

UITextView font allitasa Interface Builder-ben

A Text View attributes-ban nincs benne, de a cmd+T elohozza.

Thursday, November 4, 2010

portrait-landscape video mode

Innen:

Videos on iPhone are recorded on Quicktime format. The Quicktime format always record videos on landscape and insert metadata on the archive with the orientation information (portrait or landscape) on the moment that was recorded.

...the Transformation Matrix that Apple applies to the Quicktime on the video stream property auxMatrix.

class-dump

This is a command-line utility for examining the Objective-C runtime information stored in Mach-O files. It generates declarations for the classes, categories and protocols. This is the same information provided by using 'otool -ov', but presented as normal Objective-C declarations, so it is much more compact and readable.

SBFormattedPhoneNumber > rejection

Tobb helyen leirjak, hogy igy lehet megszerezni a telefonszamot, de ezt ugysem fogjak beengedni az App Store-ba:


CFShow([[NSUserDefaults standardUserDefaults] objectForKey:@"SBFormattedPhoneNumber"]);


Oliver Drobnik itt felsorol meg par dolgot, ami ugyan elerheto, de tiltott (UICoverFlowLayer, UIDevice setOrientation, UIAlertView addTextFieldWithValue, UIProgressHUD)

Wednesday, October 20, 2010

Brent Simmons: Demo code for playing a movie on iOS 4 using AVFoundation

NGMoviePlayer Brent Simmonstol.

SpeedLimit

SpeedLimit is a Leopard preference pane for limiting your network bandwidth to one of a couple different speeds — 768k DSL, Edge, 3G, and Dialup. This is really handy for testing your iPhone app under normal Edge network conditions in the iPhone Simulator.

Simulator forgatasnak lelassitasa

iPhone Simulator-ban Hardware/Simulate Hardware Keyboard bekapcsolasa majd 3-szor a Shift. Ezek utan lassabban fog forogni a simulator.

Thursday, October 14, 2010

Tab Bar + Action Sheet

Ha egy UITabBarController valamelyik View-jan akarunk egy UIActionSheet-et mutatni, akkor azt a TabBar-ra kell tenni es nem az eppen hasznalt View-ra, kulonben a TabBar-ra eso resze az Action Sheet-nek nek kapja meg a touch eventeket es igy a legalso gombnak (pedaul Cancel) csak a felso kicsi resze fogja erzekelni a nyomkodast.

Friday, September 10, 2010

Async kep betoltes UITableViewCell-be

Itt van az Apple peldakodja:
This sample demonstrates a multi-stage approach to loading and displaying a UITableView. It begins by loading the relevant text from an RSS feed so the table can load as quickly as possible, and then downloads the images for each row asynchronously so the UI is more responsive

vagy

Monday, August 23, 2010

Bottom Bar elrejtese amikor betoltunk egy uj View-t.

Ha egy navigation controller-ben van mondjuk alul egy Tab Bar es azt el szeretnenk rejteni egy View-n, akkor:

[myView setHidesBottomBarWhenPushed:YES];
[[self navigationController] pushViewController:myView animated:YES];

Wednesday, August 11, 2010

Josh Highland: Don't use NSLog anymore!

Azt irja, hogy nem engedik be az app store-ba azokat az appokat amikben van NSLog.

Helyette ezt javasolja:

add the following lines to the Prefix.pch file:

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define DebugLog( s, ... ) NSLog( @"<%@:(%d)> %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DebugLog( s, ... )
#endif

In your code, replace “NSLog” with “DebugLog”. THATS IT!
DebugLog adds some new functionality to NSLog. It will now output the file name and line number of the Debug statement.
The best part of this is that its very easy to disable when its time to create a release build of your code. Simple comment out the “#define DEBUG_MODE” line im the “_Prefix.pch” file.

BOOL logolasa

NSLog(@"BOOL = %@\n", (boolVar ? @"YES" : @"NO"));


Monday, August 2, 2010

AVCaptureMovieFileOutput

Remelem nem baj, ha ezt ide bemasolom:

Thursday, July 29, 2010

UIApplicationExitsOnSuspend

Ha az app-unk ugysem csinal semmit suspend modban es idegesit, hogy nem lehet egyszeruen kiloni, akkor az info.plist-hez ezt kell hozzaadni: UIApplicationExitsOnSuspend

Wednesday, July 14, 2010

UISplitViewController MasterView mutatasa portrait modban

A SplitView portrait modban automatikusan elrejti a MasterView-t es csak a DetailView-t mutatja, ahogy itt le is irjak:
"When the device is in a landscape orientation, the split view shows both panes. However, in portrait orientations, the split view displays only the second pane, which grows to fill the available space."

Egy nem dokumentalt (private) api hivassal ezt ki lehet kapcsolni:
[splitViewController setHidesMasterViewInPortrait:NO];

Csak igy valoszinuleg nem veszi be az App Store.

Az iPad alkalmazasoknak portrait es landscape modban is mukodniuk kell

iPhone-nal ez nem volt eloiras, de itt mar igen:

New) An application’s interface should support all landscape and portrait orientations. This behavior differs slightly from the iPhone, where running in both portrait and landscape modes is not required. For more information, see “Designing for Multiple Orientations.”

Wednesday, May 26, 2010

OS 4.0 > 3.1.3

Downgrade-elni hivatalosan nem lehet, de ha megis kell akkor igy.

Monday, May 3, 2010

Mike Ash: Dealing with Retain Cycles

Itt van az egesz.

"Apple's memory management guidelines state that when two objects have a parent-child relationship, the parent should retain the child. If the child needs a reference back to the parent, that reference should be an unretained, weak reference. This allows the parent to be deallocated, which can then release its reference to the child, avoiding a cycle."

Saturday, May 1, 2010

Validate Build Product

3.2-ben azokat ellenorzi amiket az App Store Review Team is fog es ahogy Jeff Lamarche is mutatja a Build Options-be kell felvenni.

Friday, April 9, 2010

Renaming an Xcode project or executable.

Tom's Cocoa Blog-rol masoltam ide az egeszet:

Renaming a project in Xcode 3.x

This seems like it ought to be a simple process provided by Xcode but it is not. Here is how to do it.

1. Copy and rename the project folder

2. Inside the new project folder rename the files ending in .pch and .xcodeproj

3. Right click on .xcodeproj file (it is actually a folder) and select show contents. In the contents folder there should be a file ending in .pbxproj. Open This file in you favorite editor and replace all instances of the old project name with the new project name.

4. Delete the build folder

5. Open the Renamed Xcode project and right click (Control click) on the Target from the groups and files list. Select Info to open the properties panel.

6. Click on the build tab the select packaging from the collection pop up menu

7. Change the value in the product name build setting to the new name.

8. Do Build Clean all Targets.

Changing the executable name

1. Open the Xcode project and right click (Control click) on the Target from the groups and files list. Select Info to open the properties panel.

2. Click on the build tab the select packaging from the collection pop up menu

3. Change the value in the product name build setting to the new name.

4. Do Build Clean all Targets.

Friday, April 2, 2010

isToday

Abizern stackoverfow-s valasza alapjan:

BOOL isToday(NSDate *date) {

NSCalendar *calendar = [NSCalendar currentCalendar];

unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;

NSDate *now = [NSDate date];

NSDateComponents *comp1 = [calendar components:unitFlags fromDate:date];

NSDateComponents *comp2 = [calendar components:unitFlags fromDate:now];

return [comp1 day] == [comp2 day] && [comp1 month] == [comp2 month] && [comp1 year] == [comp2 year];

}


Thursday, April 1, 2010

copy + paste > 2 release ugyanazon > EXC_BAD_ACCESS

Arra rajottem, hogy valahol 2 release volt, de azt valamiert nehezen talaltam meg, hogy a custom UITableViewCell dealloc-jaban csinaltam ezt. Igy utolag persze mar tok egyertelmu.

Tuesday, March 30, 2010

Igy kell megkeresni az NSDocumentDirectory-t

innen

Locating Directories as Paths

The following example illustrates how you can use the NSSearchPathForDirectoriesInDomains function to find the current user’s Documents directory:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
if ([paths count] > 0) {
    NSString *userDocumentsPath = [paths objectAtIndex:0];
    // Implementation continues...

NSSearchPathForDirectoriesInDomains simply returns the path of the appropriate directory, it does not guarantee that the directory exists. If you want to perform operations such as writing to the directory, you may have to create it first.

Monday, March 29, 2010

Refresh UITableView UIActivityIndicatorView hasznalataval

Olyasmit akartam csinalni, mint a Mail app-ban, hogy egy refresh gomb megnyomasara elkezdporogni az UIActivityIndicatorView a toolbarban, majd amikor sikerult frissiteni a szerverrol akkor visszakerul a refresh gomb. (A Mail app-ban nem tunik el a refresh gomb, de nalam igen.)

A UIViewController toolBarItems-e egy NSArray amiben a UIView-k vannak. Ugy lehet ezeket egymastol egyenlo tavolsagra tenni, ha beteszunk kozejuk olyan UIBarButtonItem-eket amiket UIBarButtonSystemFlexibleSpace-kent inicializalunk.

Elsore ugy probaltam, hogy refreshButton push-aba akartam meghivni egymas utana toolbar atvaltoztatasat, a szerverrol valo adatlekerest es a toolbar visszavaltoztatasat, ami azert se volt jo megoldas, mert ez leblokkolta volna az alkalmazast es azert sem, mert igy nem valtozott a toobar sem. Ehelyett megvaltoztatom a toolbart es egy masik thread-ben kommunikalok a szerverrel majd frissitem a tableview-t es a toolbart.


DryIcons.com - ingyenes ikonok

Itt.

Icon mellett lathato kis szam (badgeNumber) beallitasa

[[UIApplication sharedApplication] setApplicationIconBandgeNumber:42];

Tuesday, March 2, 2010

UIBarButtonItem title-jenek beallitasa

Ha a initWithBarButtonSystemItem:target:action:-nel inicializaljuk a UIBarButtonItem-et, akkor utana a setTitle nem valtoztatja meg a title-jet, ezert inkabb a initWithTitle:style:target:action:-t kell hasznalni.

Monday, March 1, 2010

NSDate to NSString

Az NSDateFormatter segitsegevel igy:

NSDate *now = [NSDate date];

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];

[dateFormat setDateStyle:NSDateFormatterFullStyle];

NSString *s = [dateFormat stringFromDate:now];

[dateFormat release];

Persze ha a setDateStyle helyett a setDateFormat-ot hasznajuk akkor a Date Formatter lehet sokfele, peldaul:
"MM.dd.yyyy. hh:mm" > "03.01.2010"
"MM/dd/yyyy hh:mma" > "03/01/2010 04:20PM"
Vagy a setDateStyle-nal maradva az NSDateFormatterStyle-bol hasznalhatjuk barmelyiket.

Monday, February 22, 2010

The UIImagePickerController class supports portrait mode only.

Ahogy a dokumentacioban is all:

Important: The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. In iPhone OS 3.1 and later, you can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.

Wednesday, February 17, 2010

Hol vannak a provisioning profile-ok a gepen.

On OSX /Users/username/Library/MobileDevice
On XP C:/Documents and Settings/username/Application Data/Apple Computer/MobileDevice/
On Vista C:/Users/username/AppData/Roaming/Apple Computer/MobileDevice/

Tuesday, February 16, 2010

NSString to NSURL

Eloszor:
- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding
Utana:
+ (id)URLWithString:(NSString *)URLString

Monday, January 18, 2010

UIView class-anak ellenorzese

Ha egy public class-rol van szo (pl UILabel) akkor konnyu megnezni:

if ([myView isKindOfClass:[UILabel class]]{

NSLog(@"myView is a UILabel");

}

de ha egy private class-ra akarom ellenorizni (pl MPFullScreenTransportControls) akkor az igy mar le sem fordulna. Ilyenkor ez is egy lehetseges megoldas:

NSString *className = NSStringFromClass([myView class]);

if (NSOrderedSame == [className compare:@"MPFullScreenTransportControls"]) {

//...

}

NSArray bejarasa "foreach"

for(id myArrayElement in myArray) {

//do something with myArrayElement

}


Friday, January 15, 2010

MPMoviePlayerController vezerlese - megoldas

Tovabbra is az a lenyeg, hogy MPMoviePlayerController-rel le tudjak jatszani egymas utan tobb movie-t es a "previous" "next" gombokkal tudjak valtogatni kozottuk valamint a Done gombra alljon le.

Volt tobb rosz megoldasom:
-megneztem, hogy MPMoviePlayerPlaybackDidFinishNotification-ben meg tudom-e allapitan miert lett vege, de erre a 3.1.2-ben nincs lehetoseg (ugyanugy kuldi a notification-t, ha vege van a movie-nak, vagy ha a megnyomta a user a done, "prev", "next" gombok valamelyiket)
-Probaltam atlatszo UIButton-okkal letakarni ezeket a gombokat es a sajat gombjaim megnyomasat lekezelni, de ez sem jo, mert a default controlok eltunnek/megjelennek es errol sincsen semmi ertesites.
-Felmerult, hogy csupa sajat UIView-val megcsinalni, ami egyreszt nem lett volna tul szep, masreszt a timeline es a volume control gondot okozott volna.

Vegul ezt a megoldast talaltam (ami egyreszt nem menne at valoszinuleg az app store-on, masreszt a kovetkezo SDK-val valtozhat is. 3.1.2-vel probaltam):

Tovabbra is felteszem az osszes controlt az MPMoviePlayerController-re (MPMovieControlModeDefault), majd igy ferek hozzajuk a UIWindowDidBecomeKeyNotification-ra feliratkozva. (Eloszor a MPMoviePlayerContentPreloadDidFinishNotification-t akartam hasznalni, de az nem volt jo. Elsore ezt nem is vettem eszre, mert az elso movie betoltesenel eloszor a keyWindow notificaton jott meg es utana a preloadDidFinish, viszont a masodik play-nel mar forditva.):

id internal;

object_getInstanceVariable(player, "_internal", (void *)&internal);

id videoViewController;

object_getInstanceVariable(internal, "_videoViewController", (void*)&videoViewController);

UIView *overlayView = [videoViewController _overlayView]; //MPFullScreenVideoOverlay


Ennek a UIView-nak pedig a subview-it siman le lehet kerni amik nagyjabol igy neznek ki. Azert nagyjabol, mert subviews egy NSArray-t ad vissza amiben az elemek sorrendje nem kotott. Azt figyeltem meg, hogy az MPFullScreenVideoOverlay-nek ha lekerem a subview-it akkor az mindig ugyanabban a sorrendben jott vissza /MPFullScreenTransportControls, NPCenteringNavigationBar/ es meg az MPFullScreenTransportControls subview-it lekerve is ugyanaz volt a sorrend /play, next, previous/, de az NPCenteringNavigationBar-nal az elso video betoltesenel UINavigationButton, UIView volt a sorrend, de a masodiknal mar pont forditva. Tehat ha subview-kat kerunk le egy NSArray-ba, akkor ne hagyatkozzunk a sorrendre, mert nem mi raktuk ossze!!!

Tehat ha igy a kezunkben van peldaul a "next" gomb, akkor arra ra is kothetjuk a sajat targetaction-unket a UIControlEventTouchUpInside-ra. Nem art elott lekotni rola a defult action-t:

[nextButton removeTarget:fstc action:nil forControlEvents:UIControlEventTouchUpInside];

[nextButton addTarget:self action:@selector(nextButtonClicked:) forControlEvents:UIControlEventTouchUpInside];


Aztan persze meg kell irni a sajat nextButtonClicked methodunkat is (meg a tobbi gombet is) amiben ha van meg lejatszando movie-nk akkor release-eljuk az MPMoviePlayerController-t majd csinalunk egy ujat a kovetkezo movie-val.>

Wednesday, January 6, 2010

MPMoviePlayerController "Previous" es "Next" button-jainak letakarasa.

Amig nem talalok megoldast ez elozo problemara, addig ugyanugy letakarom 1-1 UIButton View-val a "previous" es "next" (nem tudom mi a hivatalos nevuk) buttont, mint ahogy a Done buttonnal tettem, a minimalis CGRect pedig amivel le lehet takarni az a (36, 122, 63, 71) es a (36, 287, 63, 71) azaz a (36,122) es (99, 193) illetve a (36, 287) es (99, 358) kozotti terulet.
Igy nez ki, ha lathatova tesszuk:

UPDATE: Ez csak szimulatorban igaz, mert ott nem latszik a volume control. Az igazi device-on mashol van. Amugy sem az igazi megoldas ez, mert az overlay gombok akkor is ott lesznek, ha amugy a Default control-ok nem latszanak. Arra sajnos nincs lehetoseg, hogy megtudjuk eppen latszanak-e lejatszas kozben a default control-ok. Valoszinuleg az lesz a legjobb, ha az MPMovieControlModeHidden-re allitam es megcsinalom a sajat "Done", "Next", "Previous" controljaimat es esetleg meg egy mindig lathato controlt ami elrejti/megmutatja a tobbit. Ezzel csak az a baj, hogy igy sajat timeline control kene, amit meg nem tudom hogyan lehetne megcsinalni.

MPMediaPlayerController problemak

Tovabbra is tobb video egymas utan lejatszasat akarom megoldani es kozben belefutottam 2 problemaba:

1. Ha letrehozok egy MPMoviePlayerController-t akkor annak a retainCount-ja 1 ahogy kell, de amint meghivom rajta a play method-ot a retainCount 3 lesz. (A controller maga modul szinten van deklaralva, de ugyanez tortenik, ha helyben deklaralom, hozom letre es probalom lejatszani.) Igy persze egy sima release sem eleg a MPMoviePlayerDidFinishNotification kezeleseben. (Ugyanakkor, ha a controller-t nil-re allitom majd ujra letrehozom es meghivom a play mehtod-ot akkor mar csak 2 lesz a retainCount es nem 3.) Megneztem az Apple MoviePlayer peldakodjat es ott megjobban elszall a retainCount.

2. A masik problema, hogy ha az MPMoviePayerdidFinishNotification kezeleseben lenullazom a controller-t (akkor is, ha nil-re allitom) es utana egy masik videoval ujra letrehozom, majd meghivom rajta a play method-ot es a notification azert jott, mert a user megnyomta a "next" gombot, akkor a notification ujra megjon amint elindult a masodik video azaz a masodiknak rogton vege lesz. Ha a notification eredetileg azert jott, mert vege volt a videonak, akkor nincs ilyen problema.

Monday, January 4, 2010

UITableViewCell mozgatasa

Ha atvaltunk edit mode-ba, akkor meg nem tudjuk mozgatni a cellakat, ha nem implementaltuk (akar uresen) a tableView:moveRowAtIndexPath:toIndexPath methodot.

Ha nem akarjuk, hogy az osszes cella mozgathato legyen, akkor meg kell irni a tableView:canMoveRowAtIndexPath method-ot is.

Ha pedig nem szeretnenk, hogy akarhova at lehessen mozgatni akkor a tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath method-ot.