蓝天,小湖,湖水中一方小筑

iOS Code Snippets - UITableView

Just created a project on BitBucket to save some iOS code snippets, and the first project is a simple UITableViewController one. The code is placed at http://goo.gl/0ZrcA. The text above is the introduction text for that project, please reference the code for detailed information.

@property and its attributes

Recently working on iOS project, and have met some problems while using the attributes of @property. I have searched some documents and here is my idea about this.

Change font size of UITextView dynamically

I am working on a UITextView related problem recently, the widget, which have a fixed size, but need to show all content passed in. The text passed in have different length, so the font size should be different. The code snippet below will change the font size dynamically based on the text. // Set the text before setting font size my_text_view.text = foo_text; // Set the default font name and size int pre_defined_font_size = 14; my_text_view.

Show alert box in calendar operations of iOS6

With the new permission schema in iOS6, app should acquire authentication before accessing calendar. So the code for calendar operation should be surrounded like this: EKEventStore *eventStore = [[EKEventStore alloc] init]; EKEvent *event = [EKEvent eventWithEventStore:eventStore]; [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) { if (granted) { // Calendar operation } }]; As you can see, the code for calendar operation is written in a block. After the operation completed, you may want to show customer an alert box to say the operation is done.

Invoke map app in iOS app

最近在写个app,要调地图来展示一个地点,于是就有了三种选择:ios5之前的, 装了gmap的ios6和没装gmap的,在网上转了转,拼出来下面一段代码: