Simple way to change the position of UIView?

aView.center = CGPointMake(150, 150); // set center or aView.frame = CGRectMake( 100, 200, aView.frame.size.width, aView.frame.size.height ); // set new position exactly or aView.frame = CGRectOffset( aView.frame, 10, 10 ); // offset by an amount Edit: I didn’t compile this yet, but it should work: #define CGRectSetPos( r, x, y ) CGRectMake( x, y, r.size.width, r.size.height … Read more

Converting preview frame to bitmap

Alternatively, if you DO need a bitmap for some reason, and/or want to do this without creating a YUVImage and compressing to JPEG, you can use the handy RenderScript ‘ScriptIntrinsicYuvToRGB’ (API 17+): @Override public void onPreviewFrame(byte[] data, Camera camera) { Bitmap bitmap = Bitmap.createBitmap(r.width(), r.height(), Bitmap.Config.ARGB_8888); Allocation bmData = renderScriptNV21ToRGBA8888( mContext, r.width(), r.height(), data); bmData.copyTo(bitmap); … Read more

How to locate and click on an element which is nested within multiple frame and frameset through Selenium using Webdriver and C#

As per the HTML you have shared to click on the element with text as Login you have to induce WebDriverwait twice to switch through 2 child frame and then again to locate the desired element as follows: //SwitchTo mytestTopsubframe new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Name(“mytestTopsubframe”))); //SwitchTo mytestsubframe new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Name(“mytestsubframe”))); //Locate the desired element new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath(“//a[@class=”clslogin” … Read more

function for switching frames in python, selenium

The way this is written, it’s trying to parse CSS code as Python code. You don’t want that. This function is suitable: def frame_switch(css_selector): driver.switch_to.frame(driver.find_element_by_css_selector(css_selector)) If you are just trying to switch to the frame based on the name attribute, then you can use this: def frame_switch(name): driver.switch_to.frame(driver.find_element_by_name(name)) To switch back to the main window, … Read more

Custom MKAnnotation callout bubble with button

There are several approaches to customizing callouts: The easiest approach is to use the existing right and left callout accessories, and put your button in one of those. For example: – (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { static NSString *identifier = @”MyAnnotationView”; if ([annotation isKindOfClass:[MKUserLocation class]]) { return nil; } MKPinAnnotationView *view = (id)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; if … Read more

Calculating UILabel Text Size

All of the [NSString sizeWithFont…] methods are deprecated in iOS 7. Use this instead. CGRect labelRect = [text boundingRectWithSize:labelSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:14] } context:nil]; Also see https://developer.apple.com/documentation/foundation/nsstring/1619914-sizewithfont. UPDATE – example of boundingRectWithSize output Per your comment I did a simple test. The code and output is below. // code to generate a … Read more