iODF 项目总结
1.给View 添加背景:self.benduankou_View.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"image name.png"]];
2.自定义tableviewcell :首先新建一个空的nib文件,拖一个tableviewcell控件,再在这个控件中放入要显示的控件,这些完成后,设置File‘s owner(方法为:点击dock中的file’s owner图表,右边切换到身份检查器 (identify inspector)中,将class该为tableview的file‘s owner类),然后切换到属性检查器 修改identifier 属性,假设将其改为faLanPanCell,最后关联在file’s owner中关联的输出口,到此为止,对nib文件的操作基本结束,下面开始操作控制器文件,现在代理方法cellForRowAtIndexPath 中编写代码:
static NSString *identifier2 = @"faLanPanCell"; //对应nib文件的属性检查器中的identifier属性。
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:identifier2];//表格cell重用
if (!cell) {
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"faLanPanCell" owner:self options:nil]; //加载nib
if ([nib count]>0) {
cell = self.tvCell; //加载tableviewcell
}
UILabel *label = (UILabel *)[cell viewWithTag:1];//从cell总取出tag为1 的label
//Configure the cell
NSUInteger row=[indexPath row];
[label setText:[NSString stringWithFormat:@"%u",row]];
return cell;
3.让项目只支持横屏或竖屏 : 首先在项目.plist文件中添加一个属性,属性名为: Initial interface orientation,属性值设置为 Landscape (right home button)或Landscape (left home button);
然后在对应的ViewController.m中修改方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//UIInterfaceOrientationPortraitUpsideDown修改为对应的UIInterfaceOrientationLandscapeRight或UIInterfaceOrientationLandscapeleft即可
return (interfaceOrientation != UIInterfaceOrientationLandscapeRight);
}
4.CGPoint, CGFloat,CGRect,CGSize区别
************************************************************************
CGFloat:The basic type for all floating-point values.
************************************************************************
CGPoint :A structure that contains a point in a two-dimensional coordinate system.
struct CGPoint {
CGFloat x;
CGFloat y;
};
typedef struct CGPoint CGPoint;
Fields
x
The x-coordinate of the point.
y
The y-coordinate of the point.
************************************************************************
CGRect : A structure that contains the location and dimensions of a rectangle.
struct CGRect {
CGPoint origin;
CGSize size;
};
typedef struct CGRect CGRect;
Fields
origin
A point that specifies the coordinates of the rectangle’s origin.
size
A size that specifies the height and width of the rectangle.
Discussion
In the default Quartz coordinate space, the origin is located in the lower-left corner of the rectangle and the rectangle extends towards the upper-right corner. If the context has a flipped-coordinate space—often the case on iOS— the origin is in the upper-left corner and the rectangle extends towards the lower-right corner.
************************************************************************
CGSize
A structure that contains width and height values.
struct CGSize {
CGFloat width;
CGFloat height;
};
typedef struct CGSize CGSize;
Fields
width
A width value.
height
A height value.
************************************************************************
5.UIView 的 bounds ,frame,center属性:
************************************************************************
bounds
The bounds rectangle, which describes the view’s location and size in its own coordinate system.
@property(nonatomic) CGRect bounds
Discussion
On the screen, the bounds rectangle represents the same visible portion of the view as its frame rectangle. By default, the origin of the bounds rectangle is set to (0, 0) but you can change this value to display different portions of the view. The size of the bounds rectangle is coupled to the size of the frame rectangle, so that changes to one affect the other. Changing the bounds size grows or shrinks the view relative to its center point. The coordinates of the bounds rectangle are always specified in points.
Changing the frame rectangle automatically redisplays the receiver without invoking the drawRect: method. If you want the drawRect: method invoked when the frame rectangle changes, set the contentMode property to UIViewContentModeRedraw.
Changes to this property can be animated.
The default bounds origin is (0,0) and the size is the same as the frame rectangle’s size.
************************************************************************
frame
The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.
@property(nonatomic) CGRect frame
Discussion
This rectangle defines the size and position of the view in its superview’s coordinate system. You use this rectangle during layout operations to size and position the view. Setting this property changes the point specified by the center property and the size in the bounds rectangle accordingly. The coordinates of the frame rectangle are always specified in points.
Warning If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.
Changing the frame rectangle automatically redisplays the receiver without invoking the drawRect: method. If you want the drawRect: method invoked when the frame rectangle changes, set the contentMode property to UIViewContentModeRedraw.
Changes to this property can be animated. However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.
************************************************************************
center
The center of the frame.
@property(nonatomic) CGPoint center
Discussion
The center is specified within the coordinate system of its superview and is measured in points. Setting this property changes the values of the frame properties accordingly.
Changing the frame rectangle automatically redisplays the receiver without invoking the drawRect: method. If you want the drawRect: method invoked when the frame rectangle changes, set the contentMode property to UIViewContentModeRedraw.
Changes to this property can be animated. Use the beginAnimations:context: class method to begin and the commitAnimations class method to end an animation block.
frame描述的是在其父视图中的CGRect,而bounds描述的是在其自身视图中的CGRect,也就是说,两者所在的坐标系是不同的。

浙公网安备 33010602011771号