I have an ImageKit program that needs to be able to save images, so I'm using the IKSaveOptions accessory view, to allow the user to choose a file type, etc.
However, I want to remove some of the options, and add a checkbox to the panel for TIFFs. Alternatively, I want to add a type of file. However I can't figure out how to do this. I assume I'm going to have to subclass off of IKSaveOptions and over-ride something, but I can't find any sample code or documentation that tells me how to do this.
ETA: In particular, I need to be able to allow the user to distinguish between multi-page tiff, and a bunch of single-page tiffs with a page-number appended.
ETA: So, SO is telling me "I have only a few hours before the bounty expires so I should choose an answer" But ... there are no answers! (You'd think that SO would be smart enough to see that, but oh well B-)
IKSaveOptions is inherited from NSObject. Real accessory view is built internally and is not accessible with public API:
#interface IKSaveOptions : NSObject
{
#private
void * _privateData;
id _saveOptionsView;
}
So your best bet is to build your own save dialog accessory view with blackjack and hookers. You can start with NSView custom view in interface builder. Then it is simply:
NSSavePanel *saveDialog = [NSSavePanel savePanel];
[saveDialog setAccessoryView:mySaveAccessoryView];
VB is right, but you can get the accessory view from the NSSavePanel after it has been set by the IKSaveOptions object.
Related
Following a tutorial exactly, I created files that extend UITableViewController. The problem is that his uitableviewcontroller.m files is filled with pre written code (like the viewDidLoad), while mine is completely blank! Both our uitableviewcontroller.h files all have the code of
#import <UIKit/UIKit.h>
#interface ChemTable : UITableViewController
#property (strong,nonatomic)NSMutableArray *Chemarray;
#end
For learning purpose the auto-generated method are of least use(its perfectly ok even if You remove it). even you can create app without them....."viewDidLoad" is the one very necessary method that runs when the view is loaded, but when you go for real apps you will surely use some of auto-generated methods.
Extra -->I think you also also should see this:
ViewDidLoad - Called when you create the class and load from xib. Great for initial setup and one-time-only work
ViewWillAppear - Called right before your view appears, good for hiding/showing fields or any operations that you want to happen every time before the view is visible. Because you might be going back and forth between views, this will be called every time your view is about to appear on the screen
ViewDidAppear - Called after the view appears - great place to start an animations or the loading of external data from an API.
ViewWill/DidDisappear - Same idea as the WillAppear.
ViewDidUnload/Dispose - Available to you, but usually not necessary in Monotouch. In objective-c, this is where you do your cleanup and release of stuff, but this is handled automatically so not much you really need to do here.
I know that UIActionSheets don't offer that much customization but what I am asking, is that instead of the grayish/white buttons, can I use a green button (my own UIImage)? I can supply my own image with the text already on there that I want; so using a normal UIActionSheet, can I supply my own image on one of the buttons? If so, how should I go upon doing that?
Thanks,
O.Z
#huesforalice is right - the cleanest way would be to create your own replacement of UIActionSheet. Basically you have 3 options:
A real replacement: You create a UIActionSheet-subclass to be protocol-compatible to ´UIActionSheetDelegate´. This would allow you to use it exactly as a UIActionSheet — but it might be a costly process to figure out when and why a UIActionSheet will call the delegates method implementation.
Even go a bit further and also extend the protocol. This will give you more possibilities, how to use it (i.e. allow picker to be used via new protocol methods), but will be even harder.
The most easiest way will be to create a very own implementation, that doesn't rely on UIActionSheet nor it's protocol — but it won't replace real UIActionSheet, in the meaning that you cannot drop it into your project and expect it to work. But you will have the highest degree on freedom.
I would recommend 3. I found a project, that is working like that. But be warned: It shows you how to do it in general, but has some poor underlying design-decisions:
It uses a method
- (void) addButtonWithTitle: (NSString*) buttonTitle buttonId: (NSInteger) buttonId textColor: (UIColor*) textColor textShadowColor: (UIColor*) textShadowColor backgroundColor: (UIColor*) buttonBackgroundColor increasedSpacing: (BOOL) spacing
Instead — IMHO — it should be
- (void) addButton: (UIButton*) button;
So you can add buttons with different designs more flexible, and don't depend for a section id, what is totally unnecessary, as the object has its own identity as an object already.
The method [actionSheet showWithAnimation:YES]; should be called
showor showAnimated: as …withAnimation: usually takes a block to perform a custom animation.
This ist not possible using UIActionSheet and the documented methods. You could write your own actionsheet, which you then probably would add to the main window and animate to slide up. Possibly there is a way to do what you want by analyzing the actionsheets private view hierarchy and adding custom buttons, but you have to keep in mind, that private view hierarchies may change from one iOS Version to another, so your app might break or might even get rejected from apple.
To let you know from the beginning, I am a newbie at iPhone development, and I have taken an a monstrous task.
First of all, I am writing an application that allows to you to online shop. We have an affiliate account with a known online shopping website, are trying to tie our app into searching that site, and putting the results into a table, with hyperlinks to the site, etc.
But first problems first, one thing at a time:
In Interface Builder, I have a Search Bar, and an outlet connected to the search bar. I also have an IBAction made just to take the text that is entered into the search bar, storing it into a variable, and then searching this website (yes, that's a lot of stuff for an action).
Because I am so new at this process with IB, how do I connect the Search Bar with the IBAction? I know, stupid question.
Assuming you don't have a specific SEARCH button, set your View Controller as the delegate for UITextField and implement your action on
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
// Code here...
return YES;
}
Don't forget to declare the protocol in your interface file too
#interface ... : ... <UITextFieldDelegate>
Once that's done, everytime the GO/SEARCH key is pressed on the keyboard, it will call the method above.
[EDIT]
Here's the apple Doc for your reference http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html
You can set your view controller as the search bar's delegate in IB (or programmatically), and implement the UISearchBarDelegate protocol to define actions for your search bar.
As a beginner, you should familiarize yourself with the delegate pattern, since a lot of the iOS SDK relies on it (the iOS Application Programming Guide is a good place to start).
Update
You need to implement the UISearchBarDelegate methods in your search bar's delegate. For example, if your search bar is a property of MyViewController, you probably want to have this line in MyViewController's implementation:
[self.searchBar setDelegate:self];
It's as simple as that; now, as long as you have those methods implemented in MyViewController, they will automatically get called when the related action occurs.
I've tried to read on apple documentation but I can't find anywhere how to capture key event (space or other) into an NSDocument application.
With initialFirstRepsodner if I've understand well it's not possible to do.
Any idea?
thanks to all!
Andrea
I've tried to read on apple documentation but I can't find anywhere how to capture key event (space or other) into an NSDocument application.
What do you want to handle key events for? You need to implement keyDown: somewhere, but exactly where depends on what you intend to do.
If you want to capture all the events going to a window, you can subclass it and override -sendEvent:. If you want to capture all the events in the entire app, you can override the same method in an NSApplication subclass.
For first, I'd like to thank Peter for help!
I've used hotkey and this sample has been very usefull!
http://dbachrach.com/blog/2005/11/program-global-hotkeys-in-cocoa-easily/
thanks to all!
Andrea
First of all you have to create a subclass of NSWindow.
In xcode do: File -> New File -> Objective C Class.
give a name like "NSWindowMyEvents". That will create 2 files: .h & .m, go to the NSWindowMyEvents.h and make the declaration as follows:
#interface NSWindowMyEvents : NSWindow {
}
Save changes and compile (to be sure that IB reads the new header 0 if it is already open).
Open interface builder and load your nib/xib file that contains your Document/Main Window.
Ensure that the "window" outlet of the File's owner is set to your main window.
Click on your main Window (the one that you want to get events) and set its class (via Identity inspector cmd+6) to be: NSWindowMyEvents instead of NSWindow that it is now.
Save changes!
Go back to xcode and NSWindowMyEvents.m and paste the following code:
- (void)keyDown:(NSEvent *)theEvent
{
NSLog(#"keyDown!");
if ([[NSApp currentEvent] modifierFlags] & NSCommandKeyMask)
{
NSLog(#"CommandKey Down!");
}
[super keyDown:theEvent];
}
Send the Event to super IF you want, to pass the event to the rest responder chain.
You are now handling keyboard Events.
Similarly you can handle any event in NSWindowMyEvent.m
Hope that helps....
I would recommend using NSUserDefaults and storing your shared global key combos and then checking keyDown: against those stored preferences and then basing your actions on what key was pressed.
ie: #define kMyKeyCommand #"i"
What's the best way for registering events for my UIView subclass, so that I can connect them to IBAction-s in interface builder?
Currently I've just got a standard UIView dropped onto my main view and I've set the class to "RadioDial" (my custom class). This displays the view fine, but I have no idea how to get events out of it.
Thanks
Please clarify: do you mean that you would like Interface Builder to offer your view controllers to wire up custom events that your view subclass will be emitting (much like the Button controls allow you to wire up Touch Inside, etc)?
If you need this type of functionality, you will need to use a generalized 'delegate' property on your View combined with a protocol.
#protocol RadioDialDelegate
-(void)dialValueChanged:(id)sender
#end
#interface RadioDial
{
id<RadioDialDelegate> radioDelegate;
}
#property (nonatomic, assign) IBOutlet id<RadioDialDelegate> radioDelegate;
This will allow the controller to wire up to the view (assuming it implements RadioDialDelegate) and receive any events that come out of the view. Alternatively, you can use an untyped delegate and in your View code, use a late bound call:
if([radioDelegate respondsToSelector:#selector(dialValueChanged:)]) {
[radioDelegate dialValueChanged:self];
}
Create a method in your view controller (if nothing else, you should have a RootViewController in you project). Let's say your method is
-(void) buttonClicked { code code code }
In the controller's header file (for example RootViewController.h) you then put:
-(IBAction) buttonClicked;
And in IB you right-click your button/radio dial/whatever. You will see a list of events and you can drag FROM the connector of the event you want your controller to receive, to the object in IB that represents the controler (probably First Responder). This depends on how your IB structure is set up, but it should be straightforward.
Another alternative is to learn how to create UIViews programatically, and forget about IB for the time being. Opinions are divided about whether it's better to learn to use IB at the outset, or whether it's better to learn how to do everything in code and save IB for later. In any case, it's necessary to learn both ways of setting up an interface at some point.