Such as the following:
UIImageView * imageView6 = [[[UIImageView alloc] initWithFrame: CGRectMake (217, 132, 98, 98)] autorelease];
imageView6.image = [UIImage imageNamed: [mImage objectAtIndex: 5]];
imageView6.userInteractionEnabled = YES;
UITapGestureRecognizer * test6 = [[UITapGestureRecognizer alloc] initWithTarget: self action: @ selector (touch6)];
[ImageView6 addGestureRecognizer: test6];
[EnvironmentView addSubview: imageView6];
/ / Text description
UILabel * descriptionLable6 = [[[UILabel alloc] initWithFrame: CGRectMake ((imageView6.frame.origin.x), (imageView6.frame.origin.y) +82, 98, 16)] autorelease];
descriptionLable6.text = [mDescriptionl objectAtIndex: 5];
descriptionLable6.textColor = [UIColor whiteColor];
descriptionLable6.font = [UIFont fontWithName: @ "Arial" size: 12];
descriptionLable6.backgroundColor = [UIColor blackColor];
descriptionLable6.alpha = 0.7;
descriptionLable6.textAlignment = UITextAlignmentCenter;
[EnvironmentView addSubview: descriptionLable6];
Is a picture below to add a text. A page at least 10 to 20 of this stuff is not the same coordinates, photographs are taken from the text of the array. Other exactly.
Will future maintenance perspective, I copy and paste the above code, the fine tuning is better, or in what other ways?
I just started doing this. If there are other good ways please write about it, first to thank.
Reply:
Also, ask
Another page, lable very much, but they are not going to move.
I still think this
UILabel * descriptionLable6 = [[[UILabel alloc] initWithFrame: CGRectMake ((imageView6.frame.origin.x), (imageView6.frame.origin.y) +82, 98, 16)] autorelease];
Definition, it is no problem.
Reply:
If the style is the same, you can write a UILable extension classes, or directly written MYLable class, every time you want to use it create a label, modify the label of the attribute.
Reply:
Consider cycle dynamic loading
Well, if the interface is hundreds UILable, you still have to write repeated 100 times? A few lines of code do not get a thing
Reply:
There are an array of things, the use of cyclic loading can
Coordinate control Jiuhaola
The contents inside can also take the corresponding array.

Reply:
Know, thank you. I am now beginning to use MyLabel dynamically added. . .
There is ask, and I have every Label autorelease. A page forty or fifty. Will there be anything wrong ah? Or is this yet.
Reply:
Landlord, after the code to solve the problems, to streamline the code, solve the code redundancy, refining and other public classes, so easy to expand.
Reply:
Circulation, ah, what's with tag
Reply:
ARC also autorelease what the
Reply:
On different occasions, the package is not necessarily the perfect solution.
LZ develop a specific project, the project will usually make a lot of business because of the need child element interface and the interface. The project is one of the biggest features of variability, and this change is also difficult to predict and control.
In the face of such problems, the first idea is to change package, to deal with repetitive work with OOP thinking. But there are several issues to consider the following:
1: The program window like this more than you, if not more flowers, more than 10 components of the window contains the manually built the way they are soon.
2: Create a custom component function must be a perfect, otherwise it will not rely on the use of its components
3: Create a self-defined time and difficulty component creates more than 10 components to be longer than the manual, and maintenance time
4: Manually create 10 separate components can be more easily extended, once one of these components require special features, the established custom components need to expand, and this expansion will bring BUG.
Article 4 of the above is a little manual placement component.
Different environments can considering the surroundings and conditions, inferior race as a basis for selecting a solution, the most for the abuse of a technology can not be blindly. In the actual development project in the component packaging is also due to the imperfect development projects according to the difficulty of the situation exists.
Object-C using a delegate to replace inheritance, I think it was a kind of abuse by inheritance appears solution? (Personal humble opinion)
No comments:
Post a Comment