Skip to content

Instantly share code, notes, and snippets.

@helloworld116
helloworld116 / UISegmentedControl.m
Created March 21, 2013 09:03
ios:UISegmentedControl
//创建一个UISegmentedControl实例
NSArray *segmentTextContent = [NSArray arrayWithObjects:@"资讯",@"博客",@"推荐阅读",nil];
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:segmentTextContent];
segment.selectedSegmentIndex = 0;
segment.autoresizingMask = UIViewAutoresizingFlexibleWidth;
segment.segmentedControlStyle = UISegmentedControlStyleBar;
//UISegmentedControl实例添加事件
[segment addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged];
@helloworld116
helloworld116 / UITableDatasourceAndDelegate.m
Created March 21, 2013 05:13
ios:UITableViewDatasource和UITableViewDeletegate方法模板
#pragma mark UITableViewDataSource required method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//mode1
// NSArray *bundle = [[NSBundle mainBundle] loadNibNamed:@"AttractionCell"
// owner:self options:nil];
// AttractionCell *cell = (AttractionCell *)[bundle objectAtIndex:0];
//mode2
static NSString *cellName = @"AttractionCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
@helloworld116
helloworld116 / iphone5_related.m
Created March 21, 2013 02:14
ios:iphone5相关设置和检查
@helloworld116
helloworld116 / two-demensional-code-scran.m
Created March 19, 2013 01:53
ios:二维码扫描关键代码
//
// RootViewController.m
// ScranDemo
//
// Created by apple on 13-2-22.
// Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
//
#import "RootViewController.h"
@helloworld116
helloworld116 / AnimationViewController.m
Created March 18, 2013 02:20
ios:常用16种动画切换核心代码
//
// AnimationViewController.m
// StudyiOS
//
// Created by ZhangYiCheng on 11-9-28.
// Copyright 2011 ZhangYiCheng. All rights reserved.
//
#import "AnimationViewController.h"
#import <QuartzCore/QuartzCore.h>
@helloworld116
helloworld116 / springMVC.xml
Created March 18, 2013 02:03
java:springMVC核心配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
@helloworld116
helloworld116 / UIViewSetBackground.m
Created March 12, 2013 10:03
ios:UIView设置背景图片
//view设置背景图片
view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"dula.png"]];
@helloworld116
helloworld116 / StringHeight.m
Created March 11, 2013 09:17
ios:string:根据文字字体大小计算文字显示需要的高度
根据文字字体大小计算文字显示需要的高度
@helloworld116
helloworld116 / ViewGetBelongsViewController.m
Created March 11, 2013 09:12
ios:UIView查找所属的UIViewController
//UIView获取所属的UIViewController范例
-(BookDetailViewController *)viewController{
for (UIView *next = [self superview]; next; next = [next superview]) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[BookDetailViewController class]]) {
return (BookDetailViewController *)nextResponder;
}
}
return nil;
}
@helloworld116
helloworld116 / AsyncImageViewDemo.m
Created March 11, 2013 06:39
ios:customcontrol:AsyncImageView图片异步加载
//控件下载地址:https://github.com/nicklockwood/AsyncImageView
//imageview本身有一张默认图片,远程图片请求完后,替换为远程图片
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)