This question already has answers here:
Best way to update badgeValue of UITabBarController from a UIView
(3 answers)
Closed 9 years ago.
oh! i try to change the badge of tabbarItem in the AppDelegate;then it do work, but the tabarItem doesn't show! my code :
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UITabBarController *tabBarController = (UITabBarController *)[storyBoard instantiateViewControllerWithIdentifier:#"MainIdentifier"];
[[tabBarController.tabBar.items objectAtIndex:1] setBadgeValue:[NSString stringWithFormat:#"199"]];
(i also see the site How to set tabBarItem's badge from AppDelegate.m (tabBarView is not root View))
You can upvote the original answer here by Jim Rota
Access Tab Bar Controller:"
UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
Then set the badge
[[tabController.viewControllers objectAtIndex:1] tabBarItem].badgeValue = #"New!";
Related
This question already has answers here:
webdriver classname with space using java
(3 answers)
Closed 2 years ago.
I cant add an item to the cart because the button is not being selected.
the button in question is the "ADD TO CART" and its only classification is its class called "btn_primary btn_inventory".
this button should add the item selected to the cart as shown:
here is the non working code i used to get it to select a random button and to click on it:
WebElement areaInventory = navegador.findElement(By.id("inventory_container"));
List<WebElement> l1 = areaInventory.findElements(By.className("btn_primary btn_inventory"));
for(int i=0;i< l1.size();i++){
Random r = new Random();
l1.get(r.nextInt(6)).click();
}
Try doing the below mentioned change.
Change List<WebElement> l1 = areaInventory.findElements(By.className("btn_primary btn_inventory"));
to List<WebElement> l1 = areaInventory.findElements(By.cssSelector(".btn_primary.btn_inventory"));
This question already has answers here:
How to initialize properties that depend on each other
(4 answers)
Closed 7 years ago.
I have
var rockNamesArray:[String] = ["bird", "rock2", "rock3"]
var rockpos = Int(arc4random_uniform(UInt32(3)))
var firstrockString:String = self.rockNamesArray[rockpos]
But its telling me that rockNamesArray isnt a member. Help?
The following works perfectly in a playground.
import Foundation
var rockNamesArray:[String] = ["bird", "rock2", "rock3"]
var rockpos = Int(arc4random_uniform(UInt32(3)))
var firstrockString:String = rockNamesArray[rockpos]
it's not clear from your code if those variables are being declared inside a function or at the class level. The issue is the self. which refers to member variables so I assume the declaration is inside a function etc.
As ABakerSmith hinted - it's really easy to get to the bottom of these kinds of issues by copying & pasting the offending code into a playground.
In my app I have this property (and its #synthesize in .m)
#property (nonatomic, strong) IBOutlet UILabel *titleHeader;
in a secondViewController.
The problem is that in iOS 7 if from firstViewController I do:
[secondViewController.titleHeader setText:#"title"];
it don't work, in iOS 6 it work.
why?
EDIT
I do it:
SecondViewController *secondViewController = [[SecondViewController alloc]initWithNibName:#"SecondViewController" bundle:nil code:[object code]];
[self.navigationController pushViewController:secondViewController animated:YES];
[secondViewController.titleHeader setText:[object name]];
[secondViewController.headerView setBackgroundColor:colorHeaderGallery];
The views of secondViewController have not been loaded yet when you set them.
You can verify this by querying for the value of secondViewController.titleHeader after pushing the view controller to the navigation stack.
As a fix, you can declare a property in secondViewController
#property (nonatomic, strong) NSString *titleHeaderText;
then set that property instead of secondViewController.titleHeader setText
e.g.
secondViewController.titleHeaderText = [object name];
After that, in your secondViewController's viewDidLoad method, you can set the text of your label.
[self.titleHeader setText:self.titleHeaderText ];
EDIT:
The behavior of pushViewController seems to have changed in iOS 7.
I have tried and replicated your issue.
If you do not want the above change, a workaround is by accessing the view of secondViewController, so that its views will be loaded before you call label setText.
e.g.
SecondViewController *secondViewController = [[SecondViewController alloc]initWithNibName:#"SecondViewController" bundle:nil code:[object code]];
[self.navigationController pushViewController:secondViewController animated:YES];
[secondViewController view];
[secondViewController.titleHeader setText:[object name]];
[secondViewController.headerView setBackgroundColor:colorHeaderGallery];
This question already has answers here:
UIRefreshControl - beginRefreshing not working when UITableViewController is inside UINavigationController
(15 answers)
Closed 9 years ago.
I am not able to see the loading spinner when calling beginRefreshing
[self.refreshControl beginRefreshing];
My UITableViewController subclass uses a UIRefreshControl
// refresh
UIRefreshControl * refreshControl = [UIRefreshControl new];
[refreshControl addTarget:self action:#selector(refreshTableView) forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
It is working perfectly with user interaction (when the user drops the table down), then the spinner is visible.
But when i call beginRefreshing on viewDidLoad, I don't see the spinner (only when i drag the table down).
Notes:
self.refreshControl reference is right
reloadData or endRefreshing is not called immediately after beginRefreshing, but there is a long time delay (loading data through network), so I am not canceling the beginRefreshing.
Edit :
This only happens when the contentOffset property of the tableView is 0 and i call [self.refreshControl beginRefreshing]. Bug? Feauture?
It looks like a bug to me, because it only occures when the contentOffset property of the tableView is 0
I fixed that with the following code (method for the UITableViewController) :
- (void)beginRefreshingTableView {
[self.refreshControl beginRefreshing];
if (self.tableView.contentOffset.y == 0) {
[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^(void){
self.tableView.contentOffset = CGPointMake(0, -self.refreshControl.frame.size.height);
} completion:^(BOOL finished){
}];
}
}
Your fix looks good, But I don't think this as a bug.
When beginRefreshing method is called manually,
When there is no row / cell available it makes sense for refresh control appearing automatically.
But when there are some cells available, and when we call begin refresh manually (A scenario where we refresh periodically based on timer) then It should not animate / change the content offset as it will distract the user if he is seeing / reading content in some visible cell.
This question already has answers here:
Remove extensions from filename
(5 answers)
Closed 9 years ago.
Basically I have a column in SQL Server that has icon image names
It's kind of like
ICON
------------
Icon001
Icon002.png
Icon003.png
Icon004.png
Icon005
Icon006.png
Icon007.png
I'm trying to figure out how I can write a script to remove all of the .png from the ones that have it
I have tried
Update [dbo].[screen].[icon]
set ICON = ICON - '%.png%'
where ICON LIKE '%.png%'
But that doesn't work.
Can anybody help me?
Try
... set ICON=LEFT(icon, LEN(icon)-4 ) where ICON like '%.png'
...SET ICON = REPLACE(ICON, '.png','')
Should do the trick
Maybe something like
UPDATE icon SET icon = LEFT(icon, CHARINDEX('.png', icon) - 1) WHERE icon LIKE '%.png%'
A demo of something