This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation MyClass | |
- (void)pickAMirroredRoute { | |
MPAudioDeviceController *audoDeviceController = [[MPAudioDeviceController alloc] init]; | |
audoDeviceController.routeDiscoveryEnabled = YES; | |
[audoDeviceController determinePickableRoutesWithCompletionHandler:^(NSInteger value) { | |
NSMutableArray *routes = [NSMutableArray array]; | |
[audoDeviceController clearCachedRoutes]; | |
NSUInteger index = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static UIImage* CreateImageFromView(UITableView *view) | |
{ | |
UIGraphicsBeginImageContextWithOptions(CGSizeMake(view.contentSize.width, view.contentSize.height), NO, 0.0f); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGRect previousFrame = view.frame; | |
view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.contentSize.width, view.contentSize.height); | |
[view.layer renderInContext:context]; | |
view.frame = previousFrame; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApplicationModule extends AbstractModule { | |
private final EventBus eventBus = new EventBus("Default EventBus"); | |
@Override | |
protected void configure() { | |
bind(EventBus.class).toInstance(eventBus); | |
bindListener(Matchers.any(), new TypeListener() { | |
public <I> void hear(TypeLiteral<I> typeLiteral, TypeEncounter<I> typeEncounter) { | |
typeEncounter.register(new InjectionListener<I>() { | |
public void afterInjection(I i) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/lib${PROJECT_NAME}.a" && | |
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/lib${PROJECT_NAME}.a" && | |
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal" && | |
UNIVERSAL_LIBRARY_PATH="${UNIVERSAL_LIBRARY_DIR}/${PRODUCT_NAME}" && | |
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${PRODUCT_NAME}.framework" && | |
# Create framework directory structure. | |
rm -rf "${FRAMEWORK}" && | |
mkdir -p "${UNIVERSAL_LIBRARY_DIR}" && | |
mkdir -p "${FRAMEWORK}/Versions/A/Headers" && |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make sure MediaPlayer.framework has been added and the MPAudioVideoRoutingPopoverController interface has been declared. | |
@interface MyViewController () | |
@property (strong, nonatomic) MPAudioVideoRoutingPopoverController *airplayPopoverController; | |
@end | |
- (void)someButtonTapped:(id)sender { | |
self.airplayPopoverController = [[MPAudioVideoRoutingPopoverController alloc] initWithType:0 includeMirroring:YES]; | |
self.airplayPopoverController.delegate = self; | |
[self.airplayPopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RefreshEntityInterceptor implements MethodInterceptor { | |
@Inject | |
private Provider<EntityManager> entityManagerProvider; | |
@Inject | |
protected Logger logger; | |
@SuppressWarnings("unchecked") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doTap(x, y, numTaps, delay) | |
delay = delay or 16000; | |
local fingerId = 1; | |
for i=numTaps,1,-1 | |
do | |
touchDown(fingerId, x, y); | |
usleep(delay); | |
touchUp(fingerId, x, y); | |
usleep(delay); | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad { | |
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame: CGRectZero]; | |
self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self]; | |
self.searchController.delegate = self; | |
// Place it in view | |
searchBar.delegate = self; | |
} | |
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)text { | |
self.searchResults = [self search: text]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyViewController < UIViewController | |
def viewDidLoad | |
@search_bar = UISearchBar.alloc.initWithFrame CGRectZero | |
self.navigationController.rac_liftSelector "setNavigationBarHidden:animated:", withSignalsFromArray: [@search_bar.rac_editing, RACSignal.return(true)] | |
# Add search bar to table view, etc. | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation UISearchBar (RAC) | |
- (RACSignal *)rac_editing { | |
// Pretend we have an ivar I know we'd use setAssociatedObject | |
_proxy = [[RACDelegateProxy alloc] initWithProtocol: @protocol(UISearchBarDelegate)]; | |
return [@[ | |
[[_proxy signalForSelector: @selector(searchBarTextDidBeginEditing:)] mapReplace: @YES], | |
[[_proxy signalForSelector: @selector(searchBarTextDidEndEditing:)] mapReplace: @NO] | |
].rac_sequence.signal switchToLatest]; | |
} | |
@end |
NewerOlder