iOS

This section include about ios tutorial and code snippet.

iPhone custom tab bar

If you want to custom iphone ios tab bar you can get source code here. You can change style of tab bar like add image and change background. But, big problem is you can’t change height size of tab bar. The default height is 49 pixel for tab bar. By the way, you can get [...]

จัดการกับ orientation ของ ios

เป็นเรื่องที่น่าปวดหัวพอสมควรกับเมื่อต้องจัดการกับ orientation ของ ios ไม่ว่าจะเป็น iPhone/iPad ตอนนี้ได้คอนเซปบ้านๆแระ ผมอ่านและประยุกต์มาจากที่นี่ Easiest way to support multiple orientations ส่วนวิธีการของผมคือ สร้าง UIView สอง view ในไฟล์ .xib เดียวกัน ดูจากรูปซ้ายมือ เราก็สร้างไปว่าแนวตั้งเป็นแบบไหน แนวนอนเป็นแบบไหน จากนั้นในไฟล์ .m ของ xib นี้ เราก็ไปดูเงื่อนไขใน method willRotateToInterfaceOrientation ว่าแนวไหนของ portrait หรือ landscape เราก็กำหนด view นั้นให้มันซะ ดูตัวอย่าง code ด้าน 12345678910111213-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration { if (orientation == UIInterfaceOrientationLandscapeRight || orientation == UIInterfaceOrientationLandscapeLeft) { [...]

การเรียก (some) external app จาก iPhone/iPad

การเรียก external some app จาก iPhone iPad ในบางครั้ง ตอนพัฒนาโปรแกรม iPhone หรือ iPad ก็อยากเขียนให้มันไปเรียกโปรแกรมชาวบ้าน จะทำยังไงดีล่ะ ยกตัวอย่าง ในโปรแกรมเราที่เขียนขึ้นมา อยากให้กดปุ่มนึงแล้วไปเรียก Skype ต้องทำอย่างไร ผมไปเจอข้อมูล พบว่าการเรียก app อื่นภายนอกนั้นต้องเรียกผ่าน openURL ซึ่งเป็นฟังก์ชันนึงของ UIApplication แต่เรียกได้หรือไม่นั้นเราต้องรู้ว่า scheme url ของ app ที่เราจะเรียกคืออะไร ผมไปเจอ scheme บางส่วนที่เป็นประโยชน์มาแบ่งบันกัน ตามไปดูได้ที่ลิงค์นี้ครับ App Lookup

xcode archiving error one or more PCH files were found

This error (one or more PCH files were found) caused after I upgraded my Mac from Snow Leopard to Lion when I try to archive by builds. The solution is you need to clean build folder. You can following this step. First, click “Product” Menu Second, you will see “Clean” menu. Before selecting this menu [...]

ABPeoplePickerNavigationController remove cancel button

before after ABPeoplePickerNavigationController remove cancel button. You just add this line after new object ABPeoplePickerNavigationController. In this demo i am replace cancel button with anop72 button. [picker setAllowsCancel:NO]; You can download this demo

iphone app วัด performance ใน xcode

เขียนโปรแกรมใน iphone ก็ต้อง allocate memory, object ประจำ เราเองก็กังวลว่าพอเขียน iphone app เสร็จแล้วจะ memory leak หรือจะเจ๊งหรือเปล่า นั่งหาวิธีวัดก็ไปเจอ ซึ่งเป็น tool ที่ติดมากับ Xcode เลย อยู่ตรง Run -> Run with Performance Tool และก็จะมีให้เลือก ผมลองมาแค่อย่างเดียวคือเลือก Leak ซึ่ง tool จะบอกว่าเรา allocate ไว้ตรงไหนและเราไม่ได้คืน memory ให้กับระบบบ้าง ไว้ลองใช้ให้ครบจะมาลงอีกรอบแล้วกัน

เขียน iphone Interface Builder ระเบิด

งวยงง… เขียน app iphone อยู่แล้วมันไม่ work ไม่รู้จะทำไงก็ดันไปลอง code กับอีกโปรเจคนึง คือก๊อป code จาก proj A ไปรัน proj B ตอนก๊อปก็ก๊อป widget ต่างๆพวก ViewController ทั้งหลายในไฟล์ .xib ไปวางใน proj ใหม่ทั้งดุ้นเลย แล้วเผลอไป force closed แล้วยังไม่ได้ save สุดท้าย IB เจ๊งเลย Assertion Failure พอกด ไฟล​์ .xib ทีนี้ popup เด้งตลอดเลย แต่ก็ยังเขียนโปรแกรมได้ รันได้ปกติ แต่ต้องกด Continue ตลอด ตอนนี้ยังหาวิธีแก้ไม่เจอ ขัดใจฉิบ… ;(

Location Based Service

If you know about Location Based Service (LBS) you’ve probably heard “check in”. And last week i heard about news Sina Releases Location-Based Service For Weibo Users. I think who is interested in Location Based Service (LBS) don’t miss this news. And if you want to create you ios Location Based Service application you get [...]

Getting start iOS

If you not familiar iOS Objective-C like me. let Getting start iOS with good sample application. I think this application is good for new learn. You will learn about MVC concept, page linked, class hierarchy. You can download sample app here.

Comments are closed.