How to Customize iCarousel Coverflow like below in iOS? - ios

I have to present a view like this in the picture :
I remember that iCarrousel project can do such things, Could Any one guide me to the right control that provide this animation?
I Tried and Got Something like this
Thanks.

You need to adjust the tilt of the item views, which can be done using the carousel:valueForOption:withDefault: delegate method, like this:
- (CGFloat)carousel:(iCarousel *)carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value
{
if (option == iCarouselOptionSpacing)
{
return value * 1.5;
}
else if (option == iCarouselOptionTilt)
{
return 0.2;
}
return value;
}
The values included are just example. You'll need to tweak the title, and probably also the spacing, to avoid having the items appear to pass through each other.

The iCarousel repo includes several demo projects, one of which includes the option to display all the different types of Carousels it offers. It's been a while since I've used it, but I'm pretty sure one of the options is what you're after.
I suggest going through the demo programs and looking for the carousel type that matches what you want. Then there are a multitude of settings that you can adjust to customize the look of the carousel.

Related

UIPageViewController : Scroll Delegate

In my iOS app, I would like to set the delegate of my PageViewController's main UIScrollView.
There is tons of answer that say : "Ok man, juste iterate over subview and you will find the scrollview".
Ok, it works, but does it pass the Apple Validation Step ? Is it not a call to private API ? Does someone successfully published an app with this trick ?
Thanks everyone,
In short, no, this is not going to trip Apple's validation step. See this answer for a list of ways Apple detects private API usage. They're mostly looking for if you reference a private class or selector. For instance UIKeyboardImpl or _setViewDelegate:.
I personally have something very similar in the app store. I needed to get the UITextField in a UISearchBar so I have the following code:
UIView<UITextInput> *UISearchBarTextInput(UISearchBar *searchBar) {
for (id view in searchBar.subviews) {
// Could be in the top level. (iOS6)
if ([view conformsToProtocol:#protocol(UITextInput)]) {
return view;
}
// Or the next level. (iOS7)
for (id subview in [view subviews]) {
if ([subview conformsToProtocol:#protocol(UITextInput)]) {
return subview;
}
}
}
return nil;
}
The big problem you are likely to run into is that you are dealing with a private view hierarchy and Apple makes no guarantees that this will stay constant between iOS releases. In the code above I have to support two different iOS versions. If they decided to make a change in iOS9 I would have to make modify my code. It's a good practice in this case to assume that your lookup may fail (you won't be able to find the scroll view or a new scroll view may be added) and make your code resilient to that case.
Also, you have to consider that a human will use your app as part of the app store review. If you change things too much from the expected behavior it can be rejected on that alone.

ShinobiChart Multiple Point Selection in ScatterSeries

For my chart implementation, I want users to be able to select arbitrary data points as they see fit. The issue is that it seems like whenever another data point is selected, the previous one gets deselected. The only thing that seems to work is to have the selected BOOL as part of my data source object and then call reloadData and redrawChart on the chart with each selection.
-(void)sChart:(ShinobiChart *)chart toggledSelectionForPoint:(SChartDataPoint *)dataPoint inSeries:(SChartSeries *)series atPixelCoordinate:(CGPoint)pixelPoint {
...
myDataObject.selected = !myDataObject.selected;
dataPoint.selected = myDataObject.selected;
[self.chart reloadData];
[self.chart redrawChart];
}
And then the dataPointAtIndex will handle it.
-(id<SChartData>)sChart:(ShinobiChart *)chart dataPointAtIndex:(NSInteger)dataIndex forSeriesAtIndex:(NSInteger)seriesIndex {
...
datapoint.selected = myDataObject.selected;
}
But this seems like a wasteful, less efficient way of doing things, plus this does not have the benefit of persisting the zoom in between selections.
I think what you're looking for is series.togglePointSelection = YES. This will allow the series' points to have their selection toggled, instead of only one being set at a time.
Hope this helps!
Rob

How to define a color scheme in Xcode

I'd like to define a color scheme for my iOS project, in a way that it's easy to replace some colors. Let's say I have a "main" color and a "secondary" color, used in many elements in my app, and in a future I maybe want to set the "main" color to any other value that the one it currently has.
So far I've been using a custom UIColor category to define and use my colors in code, and creating a palette with the same colors for using it in IB and Storyboards.
This way, replacing colors in code is far straightforward, but doing it in IB and Storyboard is so painful... I didn't find an easy way to find/replace colors.
Any idea on how can I manage to do that? I'm open to any suggestion. Thank you in advance
EDIT 1: Maybe it's not clear enough in the question. I'd like to create a scheme such as I can use it both in code and in IB, but defining the colors only once, and being able to switch colors in a way that colors referenced both in code and in IB change accordingly.
An easy way i can do that in Swift:
First we have to create as many targets as we want schemes, doing click at actual scheme and select New scheme:
Creating at Assets Catalog Colors Set Colors.xcassets a color like:
Then select one Target membership at Colors.xcassets:
After that create another Colors.xcassets:
Then create again another color with same same at this new Colors.xcassets:
Then select another one Target membership at this new Colors.xcassets:
Then assign color by code using same name referenced (we use PrimaryColor), as in the following example:
struct Resources {
struct Colors {
//struct is extended in Colours
}
}
extension Colors {
struct Primary {
static let Default = UIColor(named: "PrimaryColor")!
}
}
And then the implementation:
newLabel.backgroundColor = Resources.Colors.Primary.Default
Finally depending on the scheme chosen, some colors or others will be drawn.
Another way that I have found is next link:
Protocol-Oriented Themes for iOS Apps
You can choose to loop subviews added in the parent view. And can define a set of elements you want to change colors.
So you code might look like below
-(void)defineColors:(UIView *)parent{
for(UIView *view in parent.subviews){
if(view.tag == TAG1){
[self setColor:COLOR1 forControl:view];
}else if(view.tag == TAG2){
[self setColor:COLOR2 forControl:view];
}
}
}
-(void)setColor:(UIColor *)color forControl:(UIView *)control{
if([control isKindOfClass:[UILabel class]]){
[(UILabel *)view setBackgroundColor:color];
}else if([control isKindOfClass:[UITextField class]]){
[(UITextField *)view setTextColor:color];
}
//So on..
}
I hope it helps.
Cheers.
Code Updated
You can choose to define set of tags for controls you want to assign an specific color, and then set the color accordingly..
Update 2
As per your edited question, you can have a standalone xib in which you can have different small UIView added and you can define colors from xib. Create outlets for different views. And then load the nib in AppDelegate to fetch different colors you want to use you app, and you can save them into a Singleton Class so that you can get them anytime without multiple initializations.

Using one method in place of many

I am trying to learn Objective-C for iOS. I have tried researching this, but I must not be using the right keywords.
I have several labels that are simply named, Label1, Label2, etc. I also have a ton of code that basically looks the same except the Label# changes. Can I build one method and pass the number to it and shrink my app significantly?
You probably want to have those object in an NSArray or another type of collection. Then you will be able to loop through the content and do the same operation on each element.
Consider defining a new class, CisonLabel, which abstracts out the shared behavior of these labels. The CisonLabel holds the control, and also its associated data. So you'd say
CisonLabel *label1=[CisonLabel for: self.labelControl1 withIdentifier: 1];
CisonLabel *label2=[CisonLabel for: self.labelControl2 withIdentifier: 2];
The CisonLabel would have methods like:
- (void) update; // sets the label text, based on the identifier
As DRiis suggests, you can collect all your CisonLabels in a collectionm perhaps an NSArray.
- (void) updateLabels: (NSArray*) theLabels
{
for(CisonLabel *label in theLabels) [label update];
}
Your instinct is sound: abstract out shared behavior into a class, and avoid repeating yourself.

Control selection in UITextView

I do not want the user to be able to select the first few characters of my UITextView. I have tried subclassing it and noticed methods such as -setSelectedRange: and -setSelectedTextRange:. Both are called at different times but it seems like it's the latter that I need.
The -setSelectedTextRange: method takes a UITextRange object, which has a UITextPosition property called "start". This sounds like what I want but I cannot write to it, and there are no classes for this object.
Does anyone have any ideas on how I can do this? FWIW, I'm trying to replicate what Facebook have on their "Check-In" view on their iPhone app.
Thanks in advance!
I'm not personally familiar with the functionality of the Facebook app Check-In view, but based on your description, it sounds like you need something like this in your subclass:
- (BOOL)becomeFirstResponder
{
if ([super becomeFirstResponder]) {
// Select text in field.
[self setSelectedTextRange:[self textRangeFromPosition:[self positionFromPosition:self.beginningOfDocument offset:1] toPosition:self.endOfDocument]];
return YES;
}
return NO;
}
In particular, note the "offset:1" argument. You should be able to use this to set the start of your selected text range. Also, you'll want to make sure that the new text range you specify is valid for the number of characters that are in the text field.

Resources