JTcalendar in IOS - ios

I am trying to use JTcalendar library to build a custom calendar. In the current implementation , the scroll happens when the user swipes on the screen. I need two buttons left and right to support the scroll feature.
To do this , I have added two buttons in the menu bar for left and right scroll and tried to call the viewDidScroll() function on click of either. However this is not working.
Can anyone please point me in the right direction? I can share the current implementation if needed.

Using the above suggestions, this is how I was able to do this.
The contentView that I am using is from manager object as it is available in my MenuView Class. So this is now the shared contentView.
On this I have called loadpreviouspageWithAnimation and LoadNextPageWithAnimation.
Like So,
- (void) leftAction {
[_manager.contentView loadPreviousPageWithAnimation];
}
- (void) rightAction {
[_manager.contentView loadNextPageWithAnimation];
}
Where the _manager object is already available in the menuView and leftAction and RightAction are the target methods for the buttons.
Thanks!!

You have define somewhere JTHorizontalCalendarView object like below line of code.
#property (weak, nonatomic) IBOutlet JTHorizontalCalendarView *calendarContentView;
So for next month
[_calendarContentView loadNextPage];
For previous month
[_calendarContentView loadPreviousPage];

Related

How to adjust Scrollview content size using autolayouts

Hi in my project i have added scrollview on viewcontroller and inside that scrollview i have added textfields and buttons
After that i have added auto-layouts for all fields as like below image there i have added bottom space container is "58"
but when i clicked on textfield i have changed scrollview content size like below and fine that's ok
- (void)textFieldDidBeginEditing:(UITextField *)textField;
{
[self.mainscrollview setContentSize:CGSizeMake(100, 700)];
}
here my main intention is when i clicked keyboard return button i want to set scroll view content size as like previous what i have applied
for this i have written some code but this showing exceptions please help me
#property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomSpaceContraint;
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self.mainscrollview setContentSize:(100, bottomContraint.size.height)];
return YES;
}
Your question is not really clear, but if you want to adjust the scroll view based on the presence of the keyboard use the awesome framework TPKeyboardAvoiding. Also, you have tagged your question with swift, but the code you provided is objc. You might wanna change the tag.

How to make an animated button in Apple WatchKit?

I'd like to make a button with animation in WatchKit, but it seems I can't find a way to modify WKInterfaceButton or drag an image into button in storyboard. Any help is appreciated.
After some research I found the solution, it's pretty simple but easily ignored :)
First, drag a button into a scene created in storyboard.
Second, select button, modify its property content from Text to Group. If you can't find content property, click the Attributes Inspector button at top right of your screen, it looks like a breakpoint button or a down arrow with a bar.
Now you can control group created inside your button. You need to add a reference of this WKInterfaceGroup inside your controller code. Here is an example:
#interface AAPLButtonDetailController()
#property (weak, nonatomic) IBOutlet WKInterfaceGroup *buttonGroup;
#end
#implementation AAPLButtonDetailController
- (instancetype)init {
self = [super init];
if (self) {
// Initialize variables here.
// Configure interface objects here.
[_buttonGroup setBackgroundImageNamed:#"Bus"];
[_buttonGroup startAnimating];
}
return self;
}
So the button animation will be played after scene initialized. Remember only frame animation is supported for now, all frames in one animation should be named like "Bus0.png", "Bus1.png"....
Hope this can help :)
Reck's post worked for me in instances that I needed to control the repeat count or duration. If you simply want to start or stop an animation for a button, the following works for me, where twoButton is a WKInterfaceButton and I have a set of images name Bus0#2x.png, Bus1#2x.png, etc.
- (void)startButtonAnimating
{
// This works, but can't control repeat counts or duration
[self.twoButton setBackgroundImageNamed:#"Bus"];
// But you can stop after a delay by setting background image nil
[self performSelector:#selector(stopGroupButtonAnimating) withObject:nil afterDelay:1.5];
}
- (void)stopButtonAnimating
{
[self.twoButton setBackgroundImage:nil];
}

Making button click different options within UIWebView in Xcode

I have a view controller set up with a tab bar and webView. I need to make it like that when I press the "ATC" button in the bottom of the webView, it will choose the size that the user puts in the first page, then click the "Add To Cart" button on the website. Please let me know if you need more info. Thanks in advance.
Images in dropbox links below
https://www.dropbox.com/s/he0v3m39214a6qj/Screen%20Shot%202014-09-17%20at%209.44.33%20PM.png?dl=0
https://www.dropbox.com/s/3fuvbrixlo6y5ox/Screen%20Shot%202014-09-17%20at%209.44.41%20PM.png?dl=0
In .h file do like this
#property (retain, nonatomic) IBOutlet UIButton *btnATC;
- (IBAction)btnATCPressed:(id)sender;
In .m file viewDidLoad do like this
self.btnATC.hidden = NO;
and ask size for your shoe then hide your button
- (IBAction)btnATCPressed:(id)sender
{
// ask size for your shoe ......
self.btnATC.hidden = YES;
}

How to use a custom UIButton category with Interface Builder?

I'm coding a simple card game for my younger sister on a whim. I'm using UIButtons: default state is face down, selected state is face up. I need the buttons to have a boolean property that tells me if they've ever been flipped over. If not, it gets set to true (that way I'm not just drawing random cards on each flip). I tried creating a category of UIButton called CardGameButton. In the .h file:
#interface UIButton (CardGameButton)
#property (nonatomic) BOOL discovered;
#end
In the .m file:
#implementation UIButton (CardGameButton)
#dynamic discovered;
#end
This is really all I need. How do I use this in IB? I have a bunch of UIButtons on a screen that I want to be CardGameButtons. But when I try to switch my calls to UIButton in my view controller to CardGameButton, it tells me CardGameButton isn't a type (yes I imported the file). And when I try to switch the class of the UIButtons in the storyboard to CardGameButtons, the console tells me that they're an "unknown class". I tried subclassing UIButton, but that didn't work (I just need them to be RoundedRectButtons with the extra property, and since you can't subclass RoundedRectButton they wouldn't display properly). How do I make this work in IB?
You're treating CardGameButtons as though it's a subclass of UIButton when instead it's a category. Anything you declare as UIButton will have the discovered property as standard, but you can't 'create' a CardGameButtons as it's not a thing in itself.
Categories are not types. They're just used to add some extended behavior to the class.
I suggest that you try subclassing UIButton and call it CardGameButton. Add the BOOL property to its interface. You can still make it a round rect button, by setting buttonType to UIButtonTypeRoundedRect "round rect buttons aren't a separate subclass.". Then override
- (void)sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event {
if(event.type == UIEventTypeTouches){
self.discovered = YES; // or handle the logic as you want here
}
[super sendAction:action to:target forEvent:event];
}
You can add a UIButton to your view from the IB, and then its class to your created subclass and set its type to round rect.
Edit: As you stated, buttonType is actually readOnly, so we can't use that to draw a round rect button. However, it turns out that it's not hard to draw it.
Check this tutorial. It shows how to do it using CALayer property of UIButton and using UIBezeirPath.

Check If a method Has Been Called and Do Not Call It Again

In touchesBegan I call a method [self animateWindow]; when I touch a UILabel. It animates and brings the window from top. When I touch that UILabel again, I don't want that method [self animateWindow]; to be called again because it animates and brings the window again which is already being displayed. How do I do this? Any help? I tried searching all over, couldn't find the exact answer.
Just create an instance variable which is a BOOL as use it as a flag:
#property (assign, monatomic) BOOL hasAnimated;
- (void) touchesBegan...
{
if (!self.hasAnimated) {
[self animateWindow];
self.hasAnimated = YES;
}
}
Based on your expanded description in the comments, you're going to need to add some more logic which checks which label is actually being touch. A better solution may be to use gesture recognisers on each of the labels. Then you have direct access to the view of the gesture recognizer to check which label it was (perhaps using the tag) and you can add and remove gestures depending on what state you're in (only some labels should respond to touches and they should show or hide).

Resources