hi i am new to iphone.what i am need is to place a 20 images names in an array . if i place those images in an array whether it is possible or not to change replace the first image by last means changing the positions of images dynamically if it is not possible pls suggest in what way i can done this. pls post any sample code thank u
Use NSMutableArray. It has methods like
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
- (void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2;
It does not matter whether your objects are strings or images or whatever. It is possible to change the objects in a mutable array.
Related
Is there a way to expose an array of undetermined size to the blueprint editor so that the level/game designer can adjust the size of the array?
In my example, I want an array of gunshot sound effects.
In my header file I have this:
UPROPERTY(EditAnywhere)
USoundBase* MuzzleSound[5];
... but I don't know how to do it without having to already know the size.
Over in BP I want some way to be able to adjust the size to add even more if desired:
Is this possible?
You can use a TArray. TArrays are the default array the editor uses within blueprints.
UPROPERTY(BlueprintReadWrite, EditAnywhere)
TArray<USoundBase*> MuzzleSound;
I have an array that I use to populate my pickerView, a simple string array. The issue is that I need the first item to be something like "Choose team".
The only way I have achieved that is the add the first item in the array to be "Choose team", but this messes up the array structure for me and I wonder if there is another way of doing this.
So, can I add a default value to a UIPickerValue, if no: how would you have solved this issue?
There is no easy way to add a default value. You can duplicate the array and add the string to the duplicated version for display but then you have to be careful about indexing issues. If the array's value changes programmatically, it can be a disaster. This duplication thing is not a good design anyway.
Alternatively, you can add a fixed label on right side of each picker values. Here is the example
Fixed labels in the selection bar of a UIPickerView
I am having some problem when it comes to display the steps from MKDirections route into a UILabel. I tried get each index from the steps array using the for in loop, it only show the Arrive at destination which means that all the instructions within the loop went by so fast, therefore i am seeing the last index in the array . Can someone help me please ...
it shows "Arrive at destination" because you are cycling the whole array and the label gets only the object at the end, you are basically overwriting it over and over until the for cycle arrives to its final element
You are seeing only the last value from the array in the UILabel, though it is actually displaying all the values very, very quickly. If you just want to see each of the values in the UILabel, you could either use UITimeInterval to change the value every few seconds, or add a UIButton that would handle updating of the text on the UILabel.
Is it a good idea to return thumbnail images in base64 through JSON in a RESTful call for populating UITableViewCell's? Or should one really make n requests for n images (lazy loading)? What's better?
Thanks!
You always want to start showing results to a user as fast as possible.
If your UITableView's cells will contain both text and images, get the text values first and show that, with placeholders for the graphics. Then retrieve the images (one by one, or batched up).
Also, load the images a binary values, not base64 (because base64 encoding results in more bytes being transferred).
Check out this project, it has everything you want SDWebImage
quick question...
I have a series of buttons, each with a tag. I click the buttons which individually create a uiimageview based on the tag number. So this tag number, say 43 is passed and a new uiimageview is created using 43.png
All this is working nicely and I can remove the created images by clicking on them...
..but... I'm now wondering how I can remove all these created images all at once. So I have say 4 images which were all created as a result of clicking the buttons.
my question is this: can I use a string to identify these "created" images some how? I thought about using a tag for them starting with 99 maybe? so 991, 992, 993 etc. but this doesn't seem like good coding. In the past, and indeed in Flash, I used a tag of item1, item2... then in the code, I simply loop through ALL tags on the screen starting with "item" and remove them.
any ideas on the best way to tackle this??
Thanks
You could simply store a reference to all the created images as elements in an array kept as an attribute of the viewController.
Alternatively, this is the sort of problem that can be handled with a subclass. You can just create a subclass of UIImage with some sort of identifier attribute and use that to remove them.
Seems like you could just loop through the subviews array, look at the tag property of each one, convert each to a string, and use NSString startsWith: to remove those that match your pattern.
But I think it would be easier to just keep your own list of created images, and delete them when desired.